Saturday, April 23, 2011

Session Management For Grid View Control

I recently came across a situation, where I had to use session management for GRID VIEW CONTROL.


I had a search page where there was a grid displaying some data. Whenever a search was made, the data was fetched from the back end and displayed in the grid view. Now whenever the user navigates to another page and comes back to the search page, my gridview values should be still there. 
Use the code below in the appropriate place. 

// Store GridView in Session
Session["Test"] = GridView1;
GridView1 = null;


// Retrieve GridView from Session
GridView1 = (GridView)Session["Test"];


Hope this helps!

0 comments:

Post a Comment

 

2011 ·Code-Studio by yrus.