Click here to Skip to main content
11,717,570 members (83,539 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 14-Jan-13 23:07pm
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 719
1 OriginalGriff 215
2 F-ES Sitecore 210
3 Maciej Los 140
4 Jochen Arndt 120
0 Sergey Alexandrovich Kryukov 1,494
1 OriginalGriff 535
2 Maciej Los 529
3 Richard MacCutchan 440
4 CHill60 415


Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | 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