Hi,
I am a newbie and my questions may be funny.. plzz i have this doubt is this possible?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit ChoudharyRank #145 · 15.8K reputationPosted Jun 30, 2011, 11:20 PM EDT
if its a bound grid then just single statement will work for you.
DataTable dt=(DataTable)Gridview1.DataSource;
but if you have created the grid programmatically then you have to use some loops to create the datatable.Read the Gridview row by row and insert the value in the DataRow and add it to the datatable.
Hope this make sense to you.
Thanks.
raghu v52 reputationPosted Jul 1, 2011, 1:40 AM EDT
if u know the all the datatypes of the all the rows in gridview then just create a data table with columns and then loop out the grid using for each and then make data row from each grid row and and to data table
some thing like below
datatable dt= new datatable();
datatable.Columns.Add("col1");
...
datatable.Columns.Add("coln");
foreach(gridviewrow GR in gridview1)
{
datarow dr=dt.newrow();
dr["col1"]=gr.cells(0).text;
....
dr["coln"]=gr.cells(n).text;
datatable.Rows.Add(dr);
}
this is the way u can create a data table manually from data grid
Suthish NairRank #92 · 22.8K reputationPosted Jul 1, 2011, 4:43 AM EDT
Nethra R SRank #6,347 · 269 reputationPosted Jul 3, 2011, 11:21 PM EDT
I have a gridvirew with checkboxes.. I want to display the selected rows in another gridview .. How do i do it?
Suthish NairRank #92 · 22.8K reputationPosted Jul 4, 2011, 12:15 AM EDT