Click here to Skip to main content
13,409,230 members (42,020 online)
Rate this:
 
Please Sign up or sign in to vote.
Dear Experts,

How to Print a Asp.net Gridview.

I also need to print the Header logo (Complete Header) and also Gridview.

Please help . thank u.
Posted 15-Jan-13 0:07am
Comments
RaviGupta7986 15-Jan-13 5:35am
   
you would have got answer faster if you would have entered this text in google in place of code project :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

You want to print only Gridview not entire page.

Solution is, put Gridview inside a Panel as below:

<asp: Panel runat="server" id="pnlToPrint" >
 <asp:GridView ID="gvReport" runat="server"........>
 ............
 ..............
 ............
 </asp:GridView>
</asp: Panel>
 <input type="button" value="Print"  onclick="CallPrint();" />

Now create a function as below:

function CallPrint()
{
  var printContent = document.getElementById('<%= pnlToPrint.ClientID %>');
  var printWindow = window.open("", "Print Panel", 'left=50000,top=50000,width=0,height=0');
  printWindow.document.write(prtContent.innerHTML);
  printWindow.document.close();
  printWindow.focus();
  printWindow.print();
  printWindow.close();
}
  Permalink  
Comments
Member 12963969 23-Jan-17 13:17pm
   
Thanks

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02-2016 | 2.8.180212.1 | Last Updated 19 Nov 2014
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100