protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
string s = GridView1.SelectedRow.Cells[1].Text;
string d = GridView1.SelectedRow.Cells[2].Text;
Response.Redirect("Data1.aspx?code="+s+"&name="+d);
}
FOR GETTING VALUE TO
d2.aspx
you need to pass value to that page like this..
Response.Redirect("d2.aspx?code"+s+"&name="+d);
AND ON THE
d2.aspx
Page you can get your value like this..
TextBox1.Text = Request.QueryString["code"].toString();
TextBox2.Text = Request.QueryString["name"].toString();
protected void Button1_Click(object sender, EventArgs e)
{
try
{
TextBox3.Text = TextBox1.Text;
TextBox4.Text = TextBox2.Text;
SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=me;User ID=sa;Password=windows");
SqlCommand c = new SqlCommand("INSERT INTO [deptab](depcode,depname)values(@code,@name)", con);
con.Open();
c.Parameters.AddWithValue("@code", TextBox3.Text);
c.Parameters.AddWithValue("@name", TextBox4.Text);
c.ExecuteNonQuery();
con.Close();
}
catch (Exception el)
{
el.GetBaseException();
}
}