Click here to Skip to main content
11,410,550 members (57,806 online)
Rate this: bad
good
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 at 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  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,755
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 19 Nov 2014
Copyright © CodeProject, 1999-2015
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