I have a checkboxlist with 3 checkboxes - whose values are "S", "J" and "Q"
i needed a way on the server side i.e. on the chk_SelectedIndexChanged(object sender, System.EventArgs e) event
which would let me know, as which of the 3 checkboxes got selected or unselected.
the following code would give tell me the checked-unchecked state of the 3 checkboxes but wouldnt tell me, as which of the got clicked --
ListItem lstSelf = chk.Items.FindByValue("S");
ListItem lstSelf = chk.Items.FindByValue("J");
ListItem lstSelf = chk.Items.FindByValue("Q");
Please help
valliammai muthuvalliappanPosted Jun 9, 2006, 2:57 AM
To get the server-side function OnSelectedIndexChanged to be executed you have to set the AutoPostBack to "True" for the CheckBoxList. To identify the items you selected by the OnSelectedIndexChanged use the following codings.
protected
void chk_SelectedIndexChanged(object sender, EventArgs e){
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
{
Response.Write(li.Text);
Response.Write("Selected");
}
else
{
Response.Write(li.Text);
Response.Write("NotSelected");
}
}
}
Regards,
valli.