I need to know how to keep data in a gridview after postback. I am using sqlDataAdapter with DataSet to fill the gridview. But if you want to go to the second page of the gridview list it loses the data. Would it be best to create a Session and then a list and then set the session equals to the list?
My suggestion, enclose the process that you're using to populate the gridview in the following construct:
Replace "GridViewPopulation()" with a procedure for populating your GridView control and it should only load on the initial page load and not on a postback event, hopefully preserving your GridView content.
Hope this helps :) Mark as solved if it resolves your issue.
Attaching a dataset within session and binding data from session while paging records seems very easy but I belive it create worst scenerio for resouces especially when your datatable is huge.
I recommend passing your pageNumber and PageSize parameter to your stored procedure and evaluate the paging in following way.
WITH tmp AS
ROW_NUMBER() OVER (firstColumn) AS column1,
2ndColumn AS column2,
3rdColumn AS column3,
FROM [yourTable] WITH (NOLOCK)
firstColumn = @myCondition
SN >((@PageNumber - 1) * @PageSize)
AND SN <= (@PageNumber * @PageSize)