Please note that this blog is only applicable for ASP.NET GridView and in case you are using a Grid froma Third Party source then there might be a different approach to do the same.
We have been using the below code to bind a GridView:
- DataTable dt = new DataTable();
-
- GridView1.DataSource =dt;
- GridView1.DataBind();
Now, in order to get the data from the already binded GridView, we can use the below code:
- DataTable dt = GridView1.DataSource as DataTable;
This will provide the data(including column names) as DataTable in it.
Hope it helped
Thanks
Vipul