简体   繁体   中英

How to find the value of textbox from the footer row of gridview in C# ASP.NET

        <FooterTemplate>
            <asp:TextBox ID="txtSName" runat="server" Text=""/>
        </FooterTemplate>

and the codebehind Code is as:

TextBox txtName = (TextBox)(GridView1.FooterRow.FindControl("txtSName"));
string aa=txtName.Text;

Everytime aa is null .

this code im putting into the following:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
}  

Please help me..........

Try This code it might work:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            TextBox txtName = GridView1.FooterRow.FindControl("txtSName") as TextBox;
            string aa = txtName.Text;
        }

Try this :

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
     TextBox txtName = (TextBox)e.Item.FindControl("txtSName");
} 

Let me know if it is working. Are you using this to add/update the record?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM