Populate the Dataset or Data table once

I am selecting data from SQL  then I fill a data table with data then populate a grid view with data and would like to perform the select process only one time what happened is that every time I click on gridview page or a button the data gets populated again and the order of the data has changed.

C# ASP.net
UKITAsked:
Who is Participating?
 
Paul MacDonaldDirector, Information SystemsCommented:
Put the code to fill the datatable in a section that checks for a postback:

IF NOT IsPostback THEN
  ...select for and populate datatable
END IF
0
 
FarWestCommented:
As Mr. Paul said you should manage it in IsPostback, beside you should save the dataset in session and use it if it is a PostBack, or turn on  ViewState if you only want to keep data on Grid
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.