0

Hi everybody..
I'm facing a problem in counting number of checkboxes being checked using checkboxlist. I've tried to use checkboxlist1.selecteditem, checkboxlist1.items(i).count but all in vain..
I hope any one of you can HELP me out in this problem.. THANKS....

2
Contributors
1
Reply
5
Views
12 Years
Discussion Span
Last Post by Vallim
0

Hi everybody..
I'm facing a problem in counting number of checkboxes being checked using checkboxlist. I've tried to use checkboxlist1.selecteditem, checkboxlist1.items(i).count but all in vain..
I hope any one of you can HELP me out in this problem.. THANKS....

Hi,

You can use the following code to count the total number of checkboxes in the checkboxlist have been checked.

protectedvoid Button1_Click(object sender, EventArgs e)
{
int numSelected = 0;
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
{
numSelected = numSelected + 1;
}
}
Response.Write("Total Number Of CheckBoxes Selected:");
Response.Write(numSelected);
}

Let me know if u have any doubts.

Regards,
Valli

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.