By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

Determine Empty Checkbox List

P: n/a
Hello All

I have a ASP.NET 2.0 checkbox list, the problem is when 0 items are checked
I am unable to determine if the list is empty
//Determine Checked Roles
CheckBoxList ckUserRoleList =
gvUserList.Rows[e.RowIndex].FindControl("ckUserRoleList") as CheckBoxList;
StringBuilder oStringBuilder = new StringBuilder();
foreach (ListItem li in ckUserRoleList.Items)
if (li.Selected == true) {
oStringBuilder.AppendFormat("{0},", li.Text);
if (oStringBuilder.Length != 0)
oStringBuilder.Remove(oStringBuilder.Length - 1, 1);

string[]userRoleList = (oStringBuilder.ToString().Split(new char[]
/**** Empty Values are NOT Correctly Evaluated ****/

//Add New Roles for Selected User
if (userRoleList.Length != 0)
Roles.AddUserToRoles(userName, userRoleList);

Dec 28 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.