Can you store dataset in viewstate?

Answer Posted / venkat

//create datatable
datatable dt = new datatable();
//Create new dataset :

DataSet ds = new DataSet();
ds.table.add(dt);
//Store the dataset directly into view state
ViewState["dsn"]=ds.table[0];
//retrieve the dataset where it required
DataSet ds = (DataSet)ViewState["dsn"];
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference Between Authentication and authorization?

574


Which method do you use to enforce garbage collection in .net?

515


What is voluum?

538


What are session state modes in asp.net?

547


What is the difference between mvc and asp.net? : Asp.Net MVC

474






What is the difference between application state and caching?

544


Give a few examples of page life cycle events.

670


What is Web API Routing?

602


What is use of <% %> in asp.net?

546


What are the versions of garbage collection?

1456


What is data control in asp.net?

512


What is the difference between a page theme and a global theme?

536


What is the basic difference between asp and asp.net?

518


Can you nest updatepanel within each other?

549


How do I create a web form?

528