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..
sanPosted Mar 1, 2009, 12:41 PM
Vijaya KadiyalaPosted Feb 27, 2009, 3:58 PM
Hi
Are you getting any error. I copied the same code and i can see the movement.
Thanks -- Vijaya Kadiyala
sanPosted Feb 26, 2009, 1:03 PM
Vijaya KadiyalaPosted Feb 26, 2009, 12:22 PM
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