About Me

My photo
Muthupet, TamilNadu, India
SharePoint 2010

Wednesday, December 18, 2013

How to print data from gridview control using asp.net with c#



hi,
try this code

Javascript function to print.
<script language="javascript" type="text/javascript">
    function CallPrint()
    {
        var prtContent = document.getElementById("divPrint");
        var WinPrint = window.open('','','letf=0,top=0,toolbar=0,scrollbars=0,status=0');
        WinPrint.document.write(prtContent.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close();
    }
</script>

Print Button
<asp:Button ID="btnprint" runat="server" Text="Print" OnClientClick="javascript:CallPrint();" />

GridView to Print
<div id="divPrint" style="text-align: center; width: 100%">
    <asp:GridView ID="GView" runat="server">
        <Columns>
.....
</Columns>
    </asp:GridView>
</div>

No comments:

Post a Comment