G
Guest
Is it possible to use session by cast it to an array to keep gridview primary
key?
I have the following code in place, but it gives me error saying "Unable to
cast object of type 'System.String' to type 'System.Collections.ArrayList".
Please help...
private void StoreCheckedItems()
{
ArrayList reasonIDList = new ArrayList();
int index = -1;
foreach (GridViewRow row in gvReason.Rows)
{
index = (int)gvReason.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("chkReason")).Checked;
if (Session[CHECKED_ITEMS] != null)
reasonIDList = (ArrayList)Session["CHECKED_ITEMS"];
if (result)
{
if (!reasonIDList.Contains(index))
reasonIDList.Add(index);
}
else
reasonIDList.Remove(index);
}
Thanks!
Sophie
key?
I have the following code in place, but it gives me error saying "Unable to
cast object of type 'System.String' to type 'System.Collections.ArrayList".
Please help...
private void StoreCheckedItems()
{
ArrayList reasonIDList = new ArrayList();
int index = -1;
foreach (GridViewRow row in gvReason.Rows)
{
index = (int)gvReason.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("chkReason")).Checked;
if (Session[CHECKED_ITEMS] != null)
reasonIDList = (ArrayList)Session["CHECKED_ITEMS"];
if (result)
{
if (!reasonIDList.Contains(index))
reasonIDList.Add(index);
}
else
reasonIDList.Remove(index);
}
Thanks!
Sophie