I have a panel that is being populated in my asp.net application. I need to capture the selected values (I.E. the check boxes that have been captured). This is my syntax which appears to be syntatically correct, but it is not capturing the checked checkboxes. What did I set-up incorrect?
<asp:Panel ID="pnlTest" runat="server" CssClass="scrollingControlContainer scrollingCheckBoxList">
<font class="BoldTextBlack">Select Active Students</font>
<asp:Button runat="server" ID="buttonClearCheckedBoxes" CssClass="Buttons" Text="Clear"
OnClick="buttonClearCheckedBoxes_Click" />
<br />
<asp:CheckBoxList runat="server" ID="chkBoxes" RepeatColumns="6" RepeatDirection="Horizontal"></asp:CheckBoxList>
</asp:Panel>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PopulateAllStudents();
}
}
private void PopulateAllStudents()
{
this.chkBoxes.DataSource =
this.chkBoxes.DataTextField = "StudentFullName";
this.chkBoxes.DataValueField = "StudentID";
this.chkBoxes.DataBind();
}
protected void btnClickIT_click(object sender, EventArgs e)
{
try
{
foreach (ListItem item in this.chkBoxes.Items)
{
if (item.Selected)
{
//Do Stuff Here
}
}
}
catch
{
}
}