Imagine this scenario, you have a GridView where it contains various columns as checkboxes and u want to impose a constraint that restrict the user from selecting a specific checkbox while the others are selected. ( by Unchecking the other checked checkboxes)
The following function takes as parameters GridView ID and CheckBox ID ( the one that when clicked uncheck the other checkboxes in a specific row in the gridview).
| private void SynchCheckBoxes(string gridName, string checkboxName) foreach (Control ctrl in grid.Rows[y].Controls) if (ctrls.GetType() == typeof(CheckBox) && ctrls.ID != checkboxName) } } c.Attributes.Add("onclick", "document.getElementById('" + c3.ClientID + "').checked = false;"); s.Append("document.getElementById('" + c.ClientID + "').checked = false;"); } } |
Have fun optimizing it!