Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a checkbox which consists of values(Eg: Names) taken from a datatable. I need to remove the checked values after saving the details in a form.


Eg: If the checkbox has values like "Sam","Ferin","Robin" etc.., and if i select only "Sam" and Save the form, "Sam" should not be seen after the save event. Once the form is submitted, "Sam" should be removed and the checkbox should show only "Ferin" and "Robin".

Can anyone help me out with this???


Thanks in advance..
Posted
Comments
Santosh K. Tripathi 10-Mar-15 8:10am    
what you have tried?
Sam Ferin 10-Mar-15 8:17am    
I've tried this..

for (int i = 0; i < ChkEmpNoName.Items.Count; i++)
{
if (ChkEmpNoName.Items[i].Selected == true)
{
ChkEmpNoName.Items.RemoveAt(i);
}
}

But this isn't working..
[no name] 10-Mar-15 8:11am    
You must be saving the value for which checkbox is selected.
Then just set visible = true for only those whose value is returned false from DB
Sam Ferin 10-Mar-15 8:19am    
Actually the values can be saved "n" times.. So the same Name can repeat.
Praveen Kumar Upadhyay 10-Mar-15 8:41am    
Are you loading checkbox dynamically?
You are fetching Names from database to show in checkbox.

Show some code, how you are loading checkbox values

1 solution

Quote:
Firstly, I am fetching the names form another table and loading the names in the checkboxlist in a form. and the checked values will be saved in a different table. Now my requirement is to remove the checked name from the checkboxlist.
While getting the names, you can just join the other table and get only those which don't have the checked status in that other table.

As easy as that !!!
 
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