471,350 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Determine Empty Checkbox List

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
0 1234

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.