Last active
March 23, 2018 19:04
-
-
Save rbipin/b2b76428f9028c251d26696ee2dc360a to your computer and use it in GitHub Desktop.
Aspx Gridview with a main header and subheader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' <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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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