Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a checkboxlist having some items in it ..
I had also added an item in it..
Now I want to do like this... that
when i check the item having name then all the other checkboxlist items get unchecked ...
Plzzz help me out
Posted
Updated 24-Jul-12 23:31pm
v2
Comments
graciax8 25-Jul-12 5:16am    
post your code.

Hi,

you need to use loop to uncheck all the items.
C#
foreach (ListItem li in checkboxlist.Items)
        {
            li.Selected = false;
        }
 
Share this answer
 
v2
Have you tried anything. It is simple.

Attach a javascript to the list item like this

CheckBoxList1.Items[2].Attributes.Add("onclick", "unCheckCheckList('" + CheckBoxList1.ClientID + "', '*')");

In the javascript clear the check

C#
function unCheckCheckList(table, sel_value) {
        var tableElement = document.getElementById(table);
        var children = tableElement.getElementsByTagName("input");
        for (i = 0; i < children.length; i++) {
            if (children[i].value != sel_value) {
                children[i].checked = "";
            }
        }
}
 
Share this answer
 
please find childer of type checkbox and assign checkmark in it.
 
Share this answer
 
Comments
Sandeep Mewara 25-Jul-12 5:32am    
Why opening a 1.5 yr old question and suggesting something which is not right either!

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