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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Jul 4, 2011, 4:15 AM
Nethra R SPosted Jul 4, 2011, 3:21 AM
I have a gridvirew with checkboxes.. I want to display the selected rows in another gridview .. How do i do it?
Suthish NairPosted Jul 1, 2011, 8:43 AM
raghu vPosted Jul 1, 2011, 5:40 AM
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
Amit ChoudharyPosted Jul 1, 2011, 3:20 AM
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.