我有一个问题 - 当我想用带有标题的gridview打印我的页面时 - 第二页正在打印而没有标题边框。我制作分页器以防止这种情况,但它仍然在削减 我有这样的情况:
我的代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../Content/Styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
</head>
<body onload="window.print(); window.close();">
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" HeaderStyle-BorderColor="Black" OnRowDataBound="GridView1_RowDataBound" DataSourceID="DSInsertNewDoc">
<Columns>
<asp:BoundField DataField="sgq" HeaderText="asd" SortExpression="sgq" HtmlEncode="True" />
<asp:BoundField DataField="f1" HeaderText="adad" SortExpression="f1" />
<asp:BoundField DataField="2" HeaderText="dgdghdh" SortExpression="2" />
<asp:BoundField DataField="3" HeaderText="asdaeg" SortExpression="3" />
...
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="DSD" runat="server" ConnectionString="<%$ ConnectionStrings:Context %>" SelectCommand="2018S" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="MCOD" SessionField="MCOD" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
Codebehind:
protected void Page_Load(object sender, EventArgs e)
{
DSD.SelectParameters["mcod"].DefaultValue = Request["MCOD"];
DSD.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
counter = counter + 1;
if (counter % 10 == 0)
{
e.Row.Attributes.Add("style" , "page-break-after: always;border-collapse:collapse;" );
GridView1.UseAccessibleHeader = true;
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
}