我有一个像这样的标题div:
<div id="header" style="width:100%; padding: 6px; margin-right: 20px; border-top-style: dotted; border-color: inherit; border-width: 0.2px; font-family: 'B Yekan'; font-size: 10pt;">
<p style="display:block;float:right">
<a style="right:0; font-size: 14pt; margin-right: 10px">
<asp:Label ID="lblMasir" runat="server" Text=""></asp:Label>
</a>
</p>
</div>
和标题div下div中的网格视图:
<div style="float: right; direction: rtl">
<asp:GridView Font-Names="B Nazanin" Font-Size="10pt" ID="GridView1" AllowPaging="false" AutoGenerateColumns="true" runat="server" CellPadding="6" BorderStyle="Double" OnDataBound="GridView1_DataBound" OnRowCreated="GridView1_RowCreated">
<HeaderStyle Font-Bold="True" Font-Size="9pt" />
</asp:GridView>
</div>
并且这两个潜水点位于另一个容器div中,其标题宽度与gridview width相同:
<div style="position:absolute">
<div id="header" …>
…
</div>
<br />
<div id="griddiv…>
…
</div>
</div>
那么我如何打印这个页面,在所有打印页面中重复的标题作为gridview和gridview的标题打印真正的分页。 我知道如何使用分页打印单个girdview但我不知道如果在所有页面中的网格中如何使用顶部的标题。 此致!
答案 0 :(得分:0)
my VB answer的C#版本:
private void gvExpertRateHistory_PreRender(Object sender, System.EventArgs e)
{
GridView gv = (GridView)sender;
Table InnerTable = (Table)gv.Controls[0];
if (gv.HeaderRow != null && InnerTable != null)
{
GridViewRow hr;
hr = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
hr.Cells.Add(NewCell(1, String.Empty, gv, Alignment:HorizontalAlign.Left));
hr.Cells.Add(NewCell(2, "Requested On", gv, Alignment: HorizontalAlign.Left));
hr.Cells.Add(NewCell(4, "Review Rates", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(6, "Court Rates", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(6, "Deposition Rates", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(4, "IME Rates", gv, "WhiteBorderLB"));
InnerTable.Rows.AddAt(0, hr);
hr = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
hr.Cells.Add(NewCell(1, "Expert", gv, Alignment: HorizontalAlign.Left));
hr.Cells.Add(NewCell(2, "Requested By", gv, Alignment: HorizontalAlign.Left));
hr.Cells.Add(NewCell(2, "Hourly", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Flat", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Hourly", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Daily", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Half-Day", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Hourly", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Daily", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Half-Day", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Hourly", gv, "WhiteBorderLB"));
hr.Cells.Add(NewCell(2, "Flat", gv, "WhiteBorderLB"));
InnerTable.Rows.AddAt(1, hr);
}
}
private TableHeaderCell NewCell(int colspan,
string text,
GridView gv,
string CssClass = "",
HorizontalAlign Alignment = HorizontalAlign.Center)
{
TableHeaderCell thc = new TableHeaderCell();
thc.HorizontalAlign = Alignment;
thc.ColumnSpan = colspan;
thc.Text = text;
thc.BackColor = gv.HeaderRow.BackColor;
thc.ForeColor = gv.HeaderRow.ForeColor;
thc.Font.Bold = true;
thc.CssClass = CssClass;
return thc;
}