Gridview Control have more then 100 rows of data, which is displayed in six to seven pages.
how i can Print ASP.Net GridView with page breaks and repeat header to each page.
actually i have some code which work on Internet Explorer 11.0.9600 [Windows 8.1]
but not on Google Chrome means it is not cross browser.
What changes i can do so that i will work on chrome and another browser also ?
printpage.aspx
<head>
<title>Print Monthly Society Bill</title>
<link href="../Styles/bootstrap.min.css" rel="stylesheet" />
<link href="../Styles/Style.css" rel="stylesheet" />
<script src="../Scripts/jquery-2.1.0.min.js"></script>
<script src="../Scripts/bootstrap.min.js"></script>
<script type="text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=PrintPanel.ClientID %>");
var printWindow = window.open('', '', 'height=660,width=1350');
printWindow.document.write('<html><head><title ></title>');
printWindow.document.write('</head><body class="container" >');
printWindow.document.write('<div style="text-align:left">Soceity Care Point<br />societycarepoint@gmail.com</div>');
printWindow.document.write('<div style="text-align:center"><b>Ashtam Apartment Society Bill</b></div>');
printWindow.document.write('<style type = "text/css">thead {display:table-header-group;} tfoot{display:table-footer-group;}</style>');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h1 style="text-align: center">Welcome on Printing Bill of your App</h1>
<div class="row">
<div class="container col-md-5">
<asp:DropDownList ID="ddlsocietyname" CssClass="form-control" runat="server"></asp:DropDownList>
</div>
<div class="container col-md-5">
<asp:Button ID="btnGEnerateBill" CssClass="btn btn-success" runat="server" Text="Generate Bill" OnClientClick="return PrintPanel()" OnClick="btnGEnerateBill_Click" />
</div>
</div>
</form>
</body>
Code-Behind page of printpage.aspx
protected void Page_Load(object sender, EventArgs e)
{
gvMonthlyBill.UseAccessibleHeader = true;
gvMonthlyBill.HeaderRow.TableSection = TableRowSection.TableHeader;
}
int tempcounter ;
protected void gvMonthlyBill_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
tempcounter = tempcounter + 1;
if (tempcounter == 10)
{
e.Row.Attributes.Add("style", "page-break-after: always;");
tempcounter = 0;
}
}
}