foreach (GridViewRow gr in GridView1.Rows) { if (gr.RowType == DataControlRowType.DataRow) { string strQuery1 = "select id,studentname,gender" + " from student"; DataTable dt = new DataTable(); SqlConnection con = new SqlConnection (ConfigurationManager.AppSettings["connection"].ToString()); SqlDataAdapter sda1 = new SqlDataAdapter(); SqlCommand cmd1 = new SqlCommand(strQuery1); cmd1.CommandType = CommandType.Text; cmd1.Connection = con; try { con.Open(); sda1.SelectCommand = cmd1; sda1.Fill(dt); } catch (Exception ex) { throw ex; } finally { con.Close(); sda1.Dispose(); con.Dispose(); } GridView2.DataSource = dt; GridView2.DataBind(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)