Create a gist now

Instantly share code, notes, and snippets.

Embed
Aspx Gridview with a main header and subheader
''' <summary>
''' Create a Subheader above the actual grid header
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
Protected Sub DataGrid_RowCreated(sender As Object, e As UI.WebControls.GridViewRowEventArgs) Handles datagrid.RowCreated
Dim datagrid As GridView = Nothing
Dim headercell As TableHeaderCell = Nothing
Dim gridsubheaderrow As GridViewRow = Nothing
Dim gridFooterCell As TableCell = Nothing
Try
datagrid = CType(sender, GridView)
If (e.Row.RowType = DataControlRowType.Header) Then
gridsubheaderrow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert)
headercell = New TableHeaderCell()
headercell.Text = ""
gridsubheaderrow.Cells.Add(headercell)
headercell = New TableHeaderCell()
headercell.Text = "Cash"
headercell.ColumnSpan = 3
gridsubheaderrow.Cells.Add(headercell)
headercell = New TableHeaderCell()
headercell.Text = "Check"
headercell.ColumnSpan = 3
gridsubheaderrow.Cells.Add(headercell)
headercell = New TableHeaderCell()
headercell.Text = ""
gridsubheaderrow.Cells.Add(headercell)
datagrid.Controls(0).Controls.AddAt(0, gridsubheaderrow)
End If
Catch ex As Exception
Throw
End Try
End Sub
@rbipin

This comment has been minimized.

Show comment
Hide comment
@rbipin

rbipin Mar 23, 2018

About the Snippet

This is the code snippet to create a custom header above the default aspxGridview column header. The details and the sample screenshot of the gridview is given in the blog post

Owner

rbipin commented Mar 23, 2018

About the Snippet

This is the code snippet to create a custom header above the default aspxGridview column header. The details and the sample screenshot of the gridview is given in the blog post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment