HighTechTalks DotNet Forums  

How to keep checkbox state in gridview while paging?

Dotnet General Discussions microsoft.public.dotnet.general


Discuss How to keep checkbox state in gridview while paging? in the Dotnet General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Sophie
 
Posts: n/a

Default How to keep checkbox state in gridview while paging? - 12-02-2006 , 02:01 AM






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

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.