Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have gridview with multiple page record. In one page only 27 record require to print, when i click print button only first page (27)recods printed, remaining record require nexk click,

so what i do to print multiple page record on single click

<script src="../script/jquery-1.8.3.js" type="text/javascript"></script>
<script src="../script/jquery-ui-1.10.4.custom.js" type="text/javascript"></script>
<script src="../script/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">

function PrintDivContent(divId) {
var printContent = document.getElementById(divId);
var WinPrint = window.open('', '', 'left=0,top=0,toolbar=0,sta­tus=0');

WinPrint.document.write(printContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
}

$(document).ready(function () {

$("body").keyup(function (e) {
var nkeycode = null;
nkeycode = e.keyCode;

if (nkeycode == 115) {
$("#btnprint").click();
}
});

$("#btnprint").click(function () {
PrintDivContent('divtoprint');
});
});
</script>

<div id="divtoprint">

<asp:GridView ID="GridView1" GridLines="None" HorizontalAlign="Right"
PageSize="27" AllowPaging="true"
Style="text-align:left;" Font-Size="20px"
Width="101%" runat="server"
AutoGenerateColumns="false"
onpageindexchanging="GridView1_PageIndexChanging"
onrowdatabound="GridView1_RowDataBound1" >
<Columns>
<asp:BoundField DataField="BillMasterID" ItemStyle-Width="8%" />
<asp:BoundField DataField="ConsigneeName" ItemStyle-Font-Names="Shivaji05" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="40%"/>
<asp:BoundField DataField="LocationName" ItemStyle-Font-Names="Shivaji05" ItemStyle-Width="20%"/>
<asp:BoundField DataField="TotalQuantity" ItemStyle-Width="3%" ItemStyle-HorizontalAlign="Right"/>
<asp:BoundField DataField="TotalAmount" ItemStyle-Width="19%" ItemStyle-HorizontalAlign="Right"/>
<asp:BoundField ItemStyle-Width="13%" />
</Columns>
</asp:GridView>
</div>


<table style="border-top:2px solid black; width:100%; background-color:#CDCDCD;" class="englishclass">
<tr>
<td>
<input type="button" id="btnprint" value="Print (F4)" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click1"
Text="Print" />
</td>
</tr>
</table>
Posted

1 solution

This might help you.

Printing a GridView with Paging[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900