Click here to Skip to main content
15,882,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

i have asp.net web application using c# & sql server 2008 as Database.

i have a repeater, where i have checkbox and chemical name.
it will save those which are selected, till here its ok.

but, in updating, i'm getting a problem.
if user selected 1, 2, 3 and save. instead of 1,3,4 the user selected 1,2,3.
now he want to update it.

while updating, if the record does not exists it will insert.
but, how to remove record which were not selected,
bcoz it was not selected while updating...
(insertion/update will trigger only if its selected/checked)

can anyone please help me.


thanks
Posted
Comments
hypermellow 8-Sep-14 10:56am    
Can you post the part of your code that your having problems with.
From the description above, if sounds like you are not checking if the checkbox has been selected before calling your database insertion/update routine???
ZurdoDev 8-Sep-14 11:21am    
Need more info. Please click improve question and show relevant code.

Thanks to Almighty, i got it.

i have taken one hidden field, where i'm storing chemical record id.

and any how, i have a check box.

i have put one loop,

if(hdn.value != null && checkbox.checked == false)
{
delete the record;
}


n

thanks to all of u guys for reply...
 
Share this answer
 
quick and dirty way...

when you click, you delete every past selection and than you write your selected items.

but better should be to compare selected with the esistent values, than :
- if a value exists both in selection and "database" leave as is
- if a value does not exist in "database" create it
- if a value does not exist in selection delete it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900