我在使用GridView更新,输入完更新的数据,点击更新,输入完的数据全变成了输入前的数据了,cs中传的值也都是更新前的数据,请帮帮我,谢谢
<asp:GridView ID= "GridView1 " runat= "server " AllowPaging= "True " AllowSorting= "True " AutoGenerateColumns= "False " OnPageIndexChanging= "GridView1_PageIndexChanging " OnRowEditing= "GridView1_RowEditing "
OnRowCancelingEdit= "GridView1_RowCancelingEdit " OnRowUpdating= "GridView1_RowUpdating " DataKeyNames= "ST_Teacher_id ">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields= "ST_Teacher_id " DataNavigateUrlFormatString= "ST_userlist.aspx?ST_Teacher_id={0} "
DataTextField= "ST_Teacher_id " HeaderText= "教师号 " />
<asp:BoundField DataField= "ST_Teacher_name " HeaderText= "姓名 " />
<asp:BoundField DataField= "ST_Teacher_college " HeaderText= "学院 " />
<asp:CommandField ShowEditButton= "True " />
<asp:TemplateField ShowHeader= "False ">
<ItemTemplate>
<asp:LinkButton ID= "LinkButton1 " runat= "server " CausesValidation= "False " CommandName= "Delete "
OnClientClick= 'return confirm( "确认删除吗? "); ' Text= "删除 " />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
cs:
//更新
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow gvr=this.GridView1.Rows[e.RowIndex];
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, st_conn);