【问题标题】:Print two column header in gridview在gridview中打印两列标题
【发布时间】:2013-01-18 08:10:01
【问题描述】:

我有带有两列标题的gridview,我想让它在每个页面上都可见。

标题在以下函数中创建:

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

我正在尝试使用:How to print header of GridView on each print page,当我有一列作为标题但当我尝试制作两列标题时不起作用。

任何机构都知道如何做到这一点?

谢谢 我有网格视图

【问题讨论】:

    标签: asp.net .net vb.net


    【解决方案1】:

    THEAD 是在每个打印页面上保留表格标题的元素。

    你要做的就是在网格视图上将其设置为:

    GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
    

    GridView1 是您的 GridView 的 ID。这是not yet working on google chrome

    参考:
    Having Google Chrome repeat table headers on printed pages
    Repeat table headers in print mode
    How do I get Gridview to render THEAD?

    【讨论】:

      猜你喜欢
      • 2012-03-08
      • 1970-01-01
      • 2014-09-16
      • 2014-01-10
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多