Hi,
how to get datatable from gridview???
somthing like this:
DataTable dt = gridview1.DataSource as DataTable;
-------------
I don't want to save data in session before grid binding.
-------------
Printable View
Hi,
how to get datatable from gridview???
somthing like this:
DataTable dt = gridview1.DataSource as DataTable;
-------------
I don't want to save data in session before grid binding.
-------------
Hello,
The short answer is that you can't get it back directly, I don't think. You would need to re-generate the DataTable by looping through the rows of the GridView. Something like this:
Not pretty.Code:foreach (GridViewRow row in this.GridView1.Rows)
{
DataRow dr = dt.NewRow();
dr["User Name"] = row.Cells[1].Text;
dr["User Email"] = row.Cells[2].Text;
dt.Rows.Add(dr);
}
If there is another way, I would be interested to know what that is.
Gary
I know this.... bt not confirm thats why i post this thread.....
I am searching for that another way.... i will keep open this thread for 2 or 3 days more if any1 can know much more about this...
But now I am sure it is not possible.
If this is thing possible then we can really use disconnected database. I dont want to save dataset in session caz it will create memory issues. Do u agree??
Depending on the size of the DataTable/DataSet that you are using, then yes, it can lead to memory issues. In this type of situation, you need to look at the actual data that you are pulling back to decide whether you actually need all of that data or not.
What is the actual requirement to retrieve the DataTable again? What information are you trying to get at?
Gary
thanks Gary, now I hv thinked lot and I have changed the flow of project n this is quite good and client is very happy for that n concern abt gridview to dataset is not possible or we dnt knw.
Glad to hear it :thumb: