Header & Footer in Gridview RRS feed

  • Question

  • User-797751191 posted


      How to display Header Text in Footer also in Gridview


    Wednesday, July 3, 2019 4:56 PM

All replies

  • User409696431 posted

    Set the GridView's ShowFooter attribute to true, and for each field where you have defined HeaderText, also define the same FooterText.  Simple example:

        <asp:GridView ID="GridView1" runat="server" ShowFooter="True" OnDataBound="GridView1_DataBound" DataSourceID="SqlDataSource1" >
                <asp:BoundField DataField="UserName" HeaderText="User Name" FooterText="User Name" />
                <asp:BoundField DataField="Id" HeaderText="Id" FooterText="Id" />

    Thursday, July 4, 2019 2:23 AM
  • User-1038772411 posted

    Hello, jsshivalik

    If you want to set the Header manually, you can remove the HeaderText in TemplateField, so you can set it as you want.
    For making changes in Header row you can handle RowDataBound event of GridView (sample for merging all cell in header row):
    Protected Sub gridViewData_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) 
        If e.Row.RowType = DataControlRowType.Header Then 
            e.Row.Cells(0).ColumnSpan = 5 
            e.Row.Cells(0).Text = "Amount" & "***"   'any text for header
            For i As Integer = e.Row.Cells.Count - 1 To 1 Step -1 
        End If 
    End Sub

    Please Refer Below link :



    Friday, July 12, 2019 10:10 AM