Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to uncheck all check boxes in repeater data control , other than the one being checked?
Posted
Comments
Rahul Jain, Serious Coder 31-Jan-11 13:25pm    
That means you want to toggle the checkbox state, right?

jQuery could do that on the client side very simply.

However, if you want to do it in code behind:

XML
<ItemTemplate >
    <asp:CheckBox ID="CheckBox1" runat="server"  AutoPostBack="True"
        oncheckedchanged="RepeaterCheckBox_CheckedChanged"/>



C#
protected void RepeaterCheckBox_CheckedChanged(object sender, EventArgs e)
{
    // for each data row
    foreach (RepeaterItem RE in Repeater1.Controls)
    {
        // for each control in the data row
        foreach (Control C in RE.Controls)
        {
            CheckBox CB = C as CheckBox;

            if ((CB != null) && (CB != sender))
                CB.Checked = false;
        }
    }
}
 
Share this answer
 
Comments
Sandeep Mewara 1-Feb-11 2:21am    
Good answer!
There is nothing out of the box that will do this but it can be accomplished easily with some javascript, for which there are many examples available
 
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