san

san

  • NA
  • 9
  • 0

copying rows from one gridview to another..

Feb 26 2009 5:37 AM

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..


Answers (4)