asp.net を使用する Web アプリケーションには、編集ボタンのあるグリッドビューがあります。このグリッドビューは、2 つのテーブルを結合して作成されます。これらの編集ボタンをクリックしたときに、これらの 2 つのテーブルを更新する必要があります。私のグリッドビューは、名前、nric、およびステータスの 3 つのフィールドで構成されています。両方のテーブルを更新するクエリはどうなりますか? 助けてください
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
TextBox id = (TextBox)row.FindControl("s_id");
TextBox name = (TextBox)row.FindControl("s_name");
TextBox nric = (TextBox)row.FindControl("s_nric");
TextBox status = (TextBox)row.FindControl("s_status");
SqlConnection con = obj.getcon();
con.Open();
SqlCommand cmd = new SqlCommand("update e.student_details ,f.student_vs_testsession_details set e.student_id='" + id.Text+ "',e.student_name='" + name.Text + "',e.student_nric='" + nric.Text + "',f.testsession_status='" + status.Text + "' where e.student_id=f.student_id", con);
cmd.ExecuteNonQuery();
con.Close();
}