Social Icons

Friday, 21 June 2013

Storing DataTable in ViewState in Asp.net Example using C#.Net

How to store datatable in viewstate:

Introduction:

In my previous article i explained what is viewstate in asp.net, viewstate postback count example in asp.net,WPF Architecture,Asp.Net Validation Controls Tutorial,Asp.Net Ajax Tutorial and various articles on WPF and Asp.Net. Now i will explain how to store datatable in viewstate and retrieve it back.

Description:

In this example i will get data table from database and store it in viewstate in page load event and then in button click event i will get data table from viewstate and populates it in gridview. This is the example how to store large volumes of data in viewstate.

     Take form which contains a label,a button and gridview like below

In the page load event and button click event write below code


In the page load event i am getting datatable from emp table and storing it in viewstate. in button click event i am getting viewstate emptable and binding that table to gridview. In this way you can store large amount of data in viewstate but it will increase the page size.


Conclusion:

I hope you got an idea how to store large data like datatables in viewstate.

Related Tutorials

 

No comments:

Post a comment

Please Give your Valuable Suggestions,Questions and Comments to improve my blog.