Thursday, 6 June 2013

check box list values

This code is to get the selected values from a check box list, multi selected drop
drown , list box. 
 
for (int i = 0; i < interestedIN.Items.Count; i++)
{
   if (interestedIN.Items[i].Selected)
   {
       values += interestedIN.Items[i].Value + ",";
   }
}

values = values.TrimEnd(',');
 
 
This code will explain how to bind the selected values to a check box list,list box.
 
 
 string[] strskill = skills.Split(',');
                    foreach (ListItem li in skills1.Items)
                    {
                        if (strskill.Contains(li.Value))
                            li.Selected = true;
                        else
                            li.Selected = false;
                    }

 
 
 
 

No comments:

Post a Comment