ASP.NET - how to get print all gridivew record

Asked By bhanupratap singh on 14-Feb-12 12:36 AM
Hi Everyone
I want to print all record(250 row) of my gridivew.
How Can I do This 
Web Star replied to bhanupratap singh on 14-Feb-12 12:46 AM
You can simply call window.print() that will print all things from that page so better is you can just open print popup on button clcik and put one gridview control on that popup page that will show all record without paging than you will get print all data from gridview.
simply bind all data as
GridView1.DataSource = DT;

in javascript 
function Button1_onclick() {
//open new window set the height and width =0,set windows position at bottom
var a = ('','','left =' + screen.width + ',top=' + screen.height + ',width=0,height=0,toolbar=0,scrollbars=0,status=0');
//write gridview data into newly open window
a.document.write(document.getElementById('<%= GridView1.ClientID %>').innerHTML);
//call print
return false;
dipa ahuja replied to bhanupratap singh on 14-Feb-12 12:59 AM
<script type="text/javascript">
  function CallPrint(strid) {
    var prtContent = document.getElementById(strid);
    var WinPrint ='', '', 'letf=0,top=0,width=400,height=400,toolbar=0,scrollbars=0,status=0');
<div id="divPrint">
  <%--Put Controls that you want to print--%>
<input type="button" value="print " id="btnPrint" runat="Server"
onclick="javascript:CallPrint('divPrint')" />
Somesh Yadav replied to bhanupratap singh on 14-Feb-12 01:20 AM

 i used a different approach to get the total records number.
Here is what I do:

myGridView.DataSource = myDataSet;
myGridView.DataMember = myDataSet.Tables[0];

NrOfRecords = myDataSet.Tables[0].Rows.Count;

For me it worked ok.