I have a button that creates a CheckBoxList. The items in the CheckBoxList are selected based on a user’s current notification subscriptions. I’m storing the true or false value of the selected item.
After the users change their subscriptions by checking or unchecking a box in the CheckBoxList, they click another button to update their notification subscriptions. I need to compare the Viewstate["PREV"] with the changed selections on postback and run some functions based on the changes.
ArrayList list = new ArrayList();
for (int i = 0; i < checkBoxList1.Items.Count; i++)
{
list.Add(checkBoxList1.Items[i].Selected.ToString());
}
ViewState["PREV"] = list;
Even though I can’t see the values with a Response.Write, the values for the ViewState are correct when I add a watch in debug.
The problem I’m having is how to approach the next step to do the comparison. This is what I want to accomplish:
for (int i = 0; i < checkBoxList1.Items.Count; i++)
{
//if checkbox state goes from false to true, subscribe to topic
//mySubscribeMethod
//else if checkbox state goes from true to false, unsubscribe to topic
//myUnsubscribeMethod
//else if checkbox state is unchanged, do nothing
}
You can try something like this