求助GridView控件中数据更新问题
下面是VS03里更新DataGrid的代码,怎么改为GridView下的更新代码?请指点. string st_sqlstr = "update ST_teacher set ST_Teacher_name=@teacher_name,ST_Teacher_college=@teacher_college where ST_Teacher_id=@teacher_id";
SqlCommand st_comm = new SqlCommand(st_sqlstr, con);
st_comm.Parameters.Add(new SqlParameter("@teacher_name", SqlDbType.VarChar, 50));
st_comm.Parameters.Add(new SqlParameter("@teacher_college", SqlDbType.VarChar, 50));
st_comm.Parameters.Add(new SqlParameter("@teacher_id", SqlDbType.VarChar, 50));
string st_colvalue = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
st_comm.Parameters["@teacher_name"].Value = st_colvalue;
st_colvalue = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
st_comm.Parameters["@teacher_college"].Value = st_colvalue;
st_comm.Parameters["@teacher_id"].Value = st_dtg_teacher.DataKeys[(int)e.Item.ItemIndex];
st_comm.Connection.Open();
try
{
st_comm.ExecuteNonQuery();
Lbl_note.Text = "编辑成功";
Gv_teach.EditItemIndex = -1;
}
catch (SqlException)
{
Lbl_note.Text = "编辑失败";
Lbl_note.Style["color"] = "red";
}
st_comm.Connection.Close();
St_BindGridView();