protected void Page_Load(object sender, EventArgs e)
{
BindDropList();
if (!IsPostBack)
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn();
dc.ColumnName = "Name";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "LName";
dt.Columns.Add(dc);
Session["dt"] = dt;
}
}
---------------------------------------------------------------------------------------------------
protected void Button3_Click(object sender, EventArgs e)
{
DataTable dt = (DataTable)Session["dt"];
DataRow dr;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox ch = (CheckBox)row.FindControl("asd");
if (ch.Checked==true)
{
try
{
dr = dt.NewRow();
dr["Name"] = row.Cells[1].Text;
dr["LName"] = row.Cells[2].Text;
dt.Rows.Add(dr);
}
catch (Exception ex)
{ Response.Write(ex.Message); }
}
}
GridView2.DataSource = dt;
GridView2.DataBind();
}
---------------------------------------------------------------------------------------------------