print all the records inside a gridview

Jul 27 2010 5:42 AM

hi all,
i have one gridview with paging.i want to print all the records in gridview when i click on print button that is placed outside the gridview.my problem is,when i click on print button only current page is printing.but if paging is there then also i want to print all the records.can anyone plz help me????
my code is given below...
 
<
script type="text/javascript" language="javascript">
function printfun() {
var a = window.open('', '', '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(
'innerData').innerHTML);
a.document.close();
a.focus();
//call print
a.print();
a.close();
return false;
}
</script>
 
********body part*******
<div id="innerData">

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AutoGenerateEditButton="True"
DataKeyNames="pkempid" OnRowEditing="editrecord" OnRowDeleting="deleterecord"
OnRowUpdating="updaterecord" OnRowCancelingEdit="cancelrecord" EmptyDataText="No records........."
ForeColor="#333333" GridLines="None" AllowPaging="true" PageSize="5" OnPageIndexChanging="grdView_PageIndexChanging"
Width="531px">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<span onclick="reteurn confirm('Are u sure to delete')">
<asp:LinkButton ID="linkb1" runat="server" Text="Delete" CommandName="Delete">
</asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="pkempid" HeaderText="EmployId" ReadOnly="true" />
<asp:TemplateField HeaderText="EmployName">
<ItemTemplate>
<asp:Label ID="Label22" runat="server" Text='<%# bind("empname") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtname" runat="server" Text='<%# bind("empname") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Designation">
<ItemTemplate>
<asp:Label ID="Label33" runat="server" Text='<%# bind("desig") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtdesig1" runat="server" Text='<%# bind("desig") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Phone">
<ItemTemplate>
<asp:Label ID="Label34" runat="server" Text='<%# bind("phone") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtphone1" runat="server" Text='<%# bind("phone") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="Label35" runat="server" Text='<%# bind("address") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtaddress1" runat="server" Text='<%# bind("address") %>' TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo">
<ItemTemplate>
<asp:Image ID="Image1" Height="30" Width="40" runat="server" ImageUrl='<%# bind("photo") %>' />

</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
 
<
asp:Button ID="btnPrintAll" align="center" runat="server" Text="PrintAll"
Width="236px" OnClientClick="return printfun()"/>
 
 
************************

thanks in advance
--swapna thomas---

Answers (1)