ASP.NET and C #.
I would like to have a CheckboxList with a Select All element.
- When this particular item is selected, all others will be selected too.
- When the choice is removed from this element, so will the other objects from everything.
- Checking / unchecking any other items will have an effect on this item regardless of the selection status of the Select All item.
I am looking for a jquery solution for this.
Here is the data binding code in my code:
IList<Central> Centrals = new CentralProvider().GetAllCentralsAsList();
Centrals.Insert(0, new Central(){Central_ID = 999, Central_Name = "Select All"});
CentralChecks.DataSource = Centrals;
CentralChecks.DataTextField = "Central_Name";
CentralChecks.DataValueField = "Central_ID";
CentralChecks.DataBind();
And here is the markup:
<div class="CentralDiv" id="CentralDiv">
<h2>Centrals:</h2>
<span>
<asp:TextBox ID="CentralTextBox" runat="server" CssClass="textbox">Centrals</asp:TextBox>
<img id="CentralArrow" src="images/down_arrow.jpg" style="margin-left: -22px; margin-bottom: -5px" />
</span>
<div id="CentralEffect" class="ui-widget-content">
<asp:CheckBoxList ID="CentralChecks" runat="server" onclick="GetSelectedCentralValue();">
</asp:CheckBoxList>
</div>
</div>
Please note that there are several checklist lists on the page, so any solution should consider this.
source
share