how to bind my data to asp.net controls please give me a code please
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
connect();
}
protected void GridView1_RowUpdating2(object sender, GridViewUpdateEventArgs e)
{
TextBox id = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TID");
TextBox FirstName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");
TextBox Lastname = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2");
RadioButtonList Gender = (RadioButtonList)GridView1.Rows[e.RowIndex].FindControl("RadioButtonList1");
DropDownList Qual = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1");
TextBox curemp1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3");
TextBox caddress1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox4");
DropDownList ccity1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("drp1");
TextBox paddress1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox5");
DropDownList pcity1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList2");
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = con;
cmd1.CommandText = "UPDATE tab SET firstname ='" + TextBox1.Text + "',lastname ='" + TextBox2.Text + "',gender ='" + RadioButtonList1.SelectedValue + "',qual ='" + DropDownList1.Text + "', curemp='" + TextBox3.Text + "',caddress ='" + TextBox4.Text + "',ccity ='" + drp1.Text + "',paddress ='" + TextBox5.Text + "',tpcity ='" + DropDownList2.Text + "', WHERE id='" + TID.Text + "'";
cmd1.ExecuteNonQuery();
GridView1.EditIndex = -1;
connect();
con.Close();
}
Kishore22, if this helps please login to Mark As Answer. | Alert Moderator