Adding all selected Items from CheckBox List to SortedList

Adding all selected Items from CheckBox List to SortedList in ASP.net 2.0

chkSubCategories --> A CheckBoxList Control which is already populated with some values.



using System.Collections;

SortedList objL = new SortedList();
for (int i = 0; i < chkSubCategories.Items.Count; i++)
{
if (chkSubCategories.Items[i].Selected == true)
{
objL.Add(chkSubCategories.Items[i].Value, chkSubCategories.Items[i].Text);
}
}

No comments: