我正在关注本教程,他正在使用模板字段,然后将文本框放入其中以显示数据,如下所示,
<ItemTemplate>
<asp:Label ID="lblitemUsr" runat="server" Text='<%#Eval("UserName") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtftrusrname" runat="server"/>
<asp:RequiredFieldValidator ID="rfvusername" runat="server" ControlToValidate="txtftrusrname" Text="*" ValidationGroup="validaiton"/>
</FooterTemplate>
</asp:TemplateField>
然后在更新gridview时他正在这样做,
SqlCommand cmd = new SqlCommand("update Employee_Details set City='" + txtcity.Text + "',Designation='" + txtDesignation.Text + "' where UserId=" + userid, con);
而我正在做的是,
<asp:BoundField DataField="userName" HeaderText="User" ItemStyle-Width="120px" />
现在我如何在更新 SQL 语句时获取 boundfield 值,因为没有 txtbox ?
我的 GridView 声明,
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
CellPadding="5" OnRowDataBound="GridView1_RowDataBound" Width="800px" AllowPaging="True"
PageSize="5" GridLines="Horizontal" OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting"
OnRowUpdating="GridView1_RowUpdating" OnRowEditing="GridView1_RowEditing" >