我想在 C# ASP .NET 中获取 Gridview 页脚行的文本框的值,但文本框的返回值为 null 或空。
<asp:GridView ID="GridView1" runat="server" Width="1214px"
AutoGenerateColumns="False" ShowFooter="true"
OnRowDataBound="GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Update">
<ItemTemplate>
<asp:LinkButton ID="lbtn_Update" runat="server" Text="Update"/>
<asp:LinkButton ID="lbtn_Delete" runat="server" Text="Delete"/>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lbtn_Delete" runat="server"CommandArgument="AddNew" Text="Insert"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student ID">
<EditItemTemplate>
<asp:Label ID="lblEditSID" runat="server" Text='<%#Eval("sid")%>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblSID" runat="server" Text='<%#Eval("sid")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSID" runat="server" MaxLength="50"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Name">
<EditItemTemplate>
<asp:Label ID="lblEditSName" runat="server" Text='<%#Eval("sname")%>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblSName" runat="server" Text='<%#Eval("sname")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSName" runat="server"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Mobile No">
<EditItemTemplate>
<asp:TextBox ID="txtEditMobile" runat="server" Text='<%#Eval("smno")%>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblMobile" runat="server" Text='<%#Eval("smno")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtMobile" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Email-ID">
<EditItemTemplate>
<asp:TextBox ID="txtEditEmail" runat="server" Text='<%#Eval("mailid")%>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblEmail" runat="server" Text='<%#Eval("mailid")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtEmail" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
这是后面的代码代码,我想在 C# ASP .NET 中获取 Gridview 页脚行的 Textbox 的值,但 textboxs 的 reurn 值为 null 或空
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
if (e.CommandArgument.Equals("AddNew")) {
GridView test=(GridView)sender;
TextBox txtSid = (TextBox)(test.FooterRow.FindControl("txtSID"));
TextBox txtName = (TextBox)(GridView1.FooterRow.FindControl("txtSName"));
TextBox txtMobile = (TextBox)(GridView1.FooterRow.FindControl("txtMobile"));
TextBox txtEmail = ((TextBox)GridView1.FooterRow.FindControl("txtEmail"));
string strSid =txtSid.Text;
string strName = txtName.Text;
string strMobile = txtMobile.Text;
string strEmail = txtEmail.Text;
}
}
Textxtbox 值是null
或空字符串,strName
当我将值输入文本框时,其他字符串为空。