GridView更新时,取出更新的TextBox值为什么取的有问题?
<asp:GridView ID= "dgvListPic " DataKeyNames= "ID " PageSize= "3 " AllowPaging= "true " AllowSorting= "true " AutoGenerateColumns= "false " EmptyDataText= "no data! " runat= "server " onPageIndexChanging= "dgvListPic_PageIndexChanging " OnRowEditing= "dgvListPic_RowEditing " OnRowCancelingEdit= "dgvListPic_RowCancelingEdit " OnRowUpdating= "dgvListPic_RowUpdating " width= "500 " height= "300 ">
<columns>
<asp:BoundField DataField= "ID " HeaderText= "ID "> </asp:BoundField>
<asp:TemplateField HeaderText= "图片名 ">
<itemtemplate>
<asp:Label ID= "lblPicName " runat= "server "> <%# DataBinder.Eval(Container.DataItem, "UploadName ") %> </asp:Label>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID= "txtPicName " runat= "server " Text= ' <%# DataBinder.Eval(Container.DataItem, "UploadName ") %> '> </asp:TextBox>
</edititemtemplate>
</asp:templatefield>
<asp:templatefield HeadertEXT= "操作 ">
<itemtemplate>
<asp:LinkButton ID= "lbtnEdit " runat= "server " CommandName= "Edit " Text= "编辑 " CausesValidation= "false " OnClientClick= "return Confirm( '你确定要编辑吗? '); " />
<asp:LinkButton ID= "lbtnDelete " runat= "server " CommandName= "Delete " Text= "删除 " onClientClick= "return Confirm( '你确定要删除吗? '); " />
<asp:LinkButton ID= "lbtnSelect " runat= "server " CommandName= "Select " Text= "选择 " />
</itemtemplate>
<edititemtemplate>
<asp:LinkButton ID= "lbtnUpdate " runat= "server " CommandName= "Update " Text= "修改 " />
<asp:LinkButton ID= "lbtnCancel " runat= "server " CommandName= "Cancel " Text= "取消 " />
</edititemtemplate>
</asp:templatefield>
</columns>
<AlternatingRowStyle BackColor= "#EFEFEF " />
</asp:GridView>
c#
//更新操作
protected void dgvListPic_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
string ID = dgvListPic.DataKeys[e.RowIndex].Values[0].ToString();
string dbPicName = ((TextBox)dgvListPic.Rows[e.RowIndex].FindControl( "txtPicName ")).Text;
OleDbConnection con = createConn();
con.Open();
string strSql = "UPDATE Upload SET UploadName = ' " + dbPicName + " ' WHERE ID= "+ID;
Response.Write( " <scr "+ "ipt> alert( ' "+dbPicName+ " ') </sc "+ "ript> ");
OleDbCommand cmd = new OleDbCommand(st