am having problem while copying the rows of one gridview to another..the rows are selected by checkboxes which were created using template field..the first gridview is populated by sqldatasource..for the second one am using datatable and then binding with gridview..below is the code..
DataTable dt = new DataTable(); foreach(GridViewRow gr in GridView1.Rows){
CheckBox chk = (CheckBox)(gr.FindControl("chkbx")); if (chk.Checked){
dt.Rows.Add(gr);
}
GridView2.DataSource=dt;
GridView2.DataBind();
}
can anyone help with the code...it would be greatly appreciated..

Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Feb 26, 2009, 7:22 AM EST
Hi
to find an loop through checked rows or gv1
foreach (GridViewRow objGridViewRow in ListGridView.Rows)
{
if (((CheckBox)(objGridViewRow.FindControl("AddCheckBox"))).Checked = true)
{
add as a new row to a datatable.
}
}
Bind the above datatable to gv2.
Check out the below link for more information.
http://forums.asp.net/t/1174737.aspx
Thanks -- Vijaya Kadiyala
san9 reputationPosted Feb 26, 2009, 8:03 AM EST
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Feb 27, 2009, 10:58 AM EST
Hi
Are you getting any error. I copied the same code and i can see the movement.
Thanks -- Vijaya Kadiyala
san9 reputationPosted Mar 1, 2009, 7:41 AM EST