Last post Feb 02, 2018 03:33 PM by mgebhard
Feb 02, 2018 03:22 PM|LiarLiarPantsOnFire|LINK
I am generating a DataTable then putting it into view state so that it is avaliable for other methods in my web project.
How can I take the DataTable that exists in viewstate and push to a sql server table? I was going to use SQL Bulk Copy - but do not see a tuto on how to do such with ViewState?
Feb 02, 2018 03:29 PM|A2H|LINK
but do not see a tuto on how to do such with ViewState?
You could use BulkCopy WritetoServer Method to push the changes from DataTable to SQLServer
Or if you are looking for a code to convert Viewstate to DataTable then you can use below code
//Convert Viewstate to DataTable
DataTable dt = (DataTable)ViewState["YourViewStateName"];
Feb 02, 2018 03:33 PM|mgebhard|LINK
How can I take the DataTable that exists in viewstate and push to a sql server table?
.NET has a SqlBulkCopy.WriteToServer() method.
In my experience, it is more efficient to simply store the data in the database rather than caching the data in ViewState. Especially ViewState as ViewState is stored in a hidden field within the Web Page.