Search code examples
c#asp.netgridviewfooter

how to add the footer row dynamically in gridview. with textboxes


how to add the footer row dynamically in gridview. with textboxes.. pls give any idea...


Solution

  • Since there can be only one footer row in the grid view IMO it is better to add the footer row by setting the ShowFooter property of the grid view to true. Setting the FooterStyle property can be helpful here.

    When coming to the programming part,

    protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {            
        TextBox txt = new TextBox();
              // set properties of text box
        e.Row.Cells[0].Controls.Add(txt);
        }
    }
    

    Try this and comment.

    Edit : This will be helpful http://www.asp.net/data-access/tutorials/displaying-summary-information-in-the-gridview-s-footer-cs