Reputation: 11
I have gridview with header with two columns and I want to make to be visible on each page.
Header is created in following function:
Protected Sub grdOriginal_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdOriginal.RowCreated
If e.Row.RowType = DataControlRowType.Header Then
Dim HeaderRow As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert)
Dim Cell_Header As TableCell = New TableCell()
Cell_Header = New TableCell()
Cell_Header.Text = "Ознака табле"
Cell_Header.HorizontalAlign = HorizontalAlign.Center
Cell_Header.Width = "150"
Cell_Header.RowSpan = 2
Cell_Header.Font.Bold = True
HeaderRow.Cells.Add(Cell_Header)
Cell_Header = New TableCell()
Cell_Header.Text = "Површине делова табли по процембеним разредима"
Cell_Header.HorizontalAlign = HorizontalAlign.Center
Cell_Header.Width = "370"
Cell_Header.Font.Bold = True
Cell_Header.ColumnSpan = 8
HeaderRow.Cells.Add(Cell_Header)
Cell_Header = New TableCell()
Cell_Header.Text = "Укупна површина табле"
Cell_Header.HorizontalAlign = HorizontalAlign.Center
Cell_Header.Width = "70"
Cell_Header.RowSpan = 2
Cell_Header.Font.Bold = True
HeaderRow.Cells.Add(Cell_Header)
Cell_Header = New TableCell()
Cell_Header.Text = "Укупна вредност табле"
Cell_Header.HorizontalAlign = HorizontalAlign.Center
Cell_Header.Width = "70"
Cell_Header.RowSpan = 2
Cell_Header.Font.Bold = True
HeaderRow.Cells.Add(Cell_Header)
Cell_Header = New TableCell()
Cell_Header.Text = "Примедба"
Cell_Header.HorizontalAlign = HorizontalAlign.Center
Cell_Header.Width = "70"
Cell_Header.RowSpan = 2
Cell_Header.Font.Bold = True
HeaderRow.Cells.Add(Cell_Header)
e.Row.Cells(0).Visible = False
e.Row.Cells(9).Visible = False
e.Row.Cells(10).Visible = False
e.Row.Cells(11).Visible = False
'e.Row.Cells(4).Visible = False
'e.Row.Cells(12).Visible = False
'e.Row.Cells(13).Visible = False
'e.Row.Cells(14).Visible = False
grdOriginal.Controls(0).Controls.AddAt(0, HeaderRow)
End If
End Sub
I’m try to use: How to print header of GridView on each print page, This working when I have one column for header but don’t working when I try to make two columns header.
Any body have any idea how to do that?
Thanks I have gridview whith
Upvotes: 1
Views: 852
Reputation: 66641
The THEAD is the element that keeps the header of the table on each printed page.
What you have to do is to set it on the grid view as:
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
where GridView1
is the id of your GridView. This is not yet working on google chrome.
reference:
Having Google Chrome repeat table headers on printed pages
Repeat table headers in print mode
How do I get Gridview to render THEAD?
Upvotes: 1