ricy101 0 Newbie Poster

dear readers, i have a checkboxlist control in a formview and i am trying to save the state of the selected item during paging the form. i have been able to save the values in a dictionary list stored in a viewstate. i am having problems populating the right seletected item in the contol. i saved the index of the form as the key and the value as the index of the checkboxlist item. when i check a box every other check-box are selected with the same index in different formview page-index e.g
chk index 0 on page index 0
chk index 0 on page index 1
and it goes on like that.
here are my codes.

public Dictionary<int, int> items
        {
            get
            {
                object d = ViewState["Items"];
                return (d == null ? null : (Dictionary<int, int>)d);
            }
            set
            {
                ViewState["Items"] = value;
            }
        }
public void StoreValues()
        {
            Dictionary<int, int> ids = new Dictionary<int, int>();
            for (int i = fvQuestion.PageIndex; i < fvQuestion.PageCount; i++)
            {
                HiddenField answerType = (HiddenField)fvQuestion.Row.FindControl("HiddenField1");
                switch (answerType.Value)
                {
                    case "mc":
                        CheckBoxList chkList = (CheckBoxList)fvQuestion.Row.FindControl("chkList");
                        for (int ia = 0; ia < chkList.Items.Count; ia++)
                        {
                            if (chkList.Items[ia].Selected)
                            {
                                if (!ids.ContainsKey(i))
                             a   {
                                    if (!ids.ContainsValue(ia))
                                    {
                                        ids.Add(i, ia);
                                    }
                                    else
                                    {
                                        ids.Remove(i);
                                    }
                                }
                            }
                        }
                        if (ids != null)
                            items = ids;
                        break;
                }
            } 
        }
public void PupulateoldCheckValue()
        {
            Dictionary<int, int> dicList = (Dictionary<int, int>)items;
            if (dicList != null && dicList.Count > 0)
            {
                for (int i = 0; i < fvQuestion.PageCount; i++)
                {

                    HiddenField answerType = (HiddenField)fvQuestion.Row.FindControl("HiddenField1"); switch (answerType.Value)
                    {
                        case "mc":
                            CheckBoxList chkList = (CheckBoxList)fvQuestion.Row.FindControl("chkList");
                            for (int ia = 0; ia < chkList.Items.Count; ia++)
                            {
                                if (dicList.ContainsKey(i) && dicList.ContainsValue(ia))
                                {
                                    chkList.Items[ia].Selected = true;
                                }
                            }
                            break;
                    }
                }
            }
        }

thanks