Hi,
I am populating the checkboxlist in (!IsPostBack) block of page load event
with some checked items.
After populating with checked items I am iterating through the items collection and applying color style for checked items.
The below method is called from !IsPostBack()
The Issue:
when the page is postedback, checkboxlist retaining its selections but losing its color style for selected items.
Please let me know why , the applied style attribute is not loaded in to viewstate.
Thanx & Regards,
only
I am populating the checkboxlist in (!IsPostBack) block of page load event
with some checked items.
After populating with checked items I am iterating through the items collection and applying color style for checked items.
The below method is called from !IsPostBack()
Code:
public static void PopulateCheckBoxList(CheckBoxList checkBoxList, ArrayList nameValueList, ArrayList selectedItemsList)
{
checkBoxList.Items.Clear();
foreach (NameValueItem item in nameValueList)
{
ListItem li = new ListItem(item.ItemName, item.ItemValue.ToLower());
checkBoxList.Items.Add(li);
}
foreach (NameValueItem item in selectedItemsList)
{
checkBoxList.Items.FindByValue(item.ItemValue.ToLower()).Selected = true;
checkBoxList.Items.FindByValue(item.ItemValue.ToLower()).Attributes.Add("class", "selectedCheckBoxListItem");
}
}
when the page is postedback, checkboxlist retaining its selections but losing its color style for selected items.
Please let me know why , the applied style attribute is not loaded in to viewstate.
Thanx & Regards,
only
Comment