Click here to Skip to main content
15,885,771 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i want to print the data from gridview on button click... i am using master page concept.
XML
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript">

    function PrintGridData() {
        var prtGrid = document.getElementById('grdreport');
        prtGrid.border = 0;
        var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
        prtwin.document.write(prtGrid.outerHTML);
        prtwin.document.close();
        prtwin.focus();
        prtwin.print();
        prtwin.close();
    }
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:GridView ID="grdreport" runat="server" ></asp:GridView>
</asp:Content>

its not working
Posted
v2
Comments
jaideepsinh 21-Aug-13 2:50am    
Can you explain in detail?
Where are you calling this PrintGridData() ?
BulletVictim 21-Aug-13 4:31am    
Where is your print button?
This is just thinking out loud. In the button deceleration- OnClick or OnClientClick call the PrintGridData().
Just a thought.
Also why use the PrintGridData() in the master page? Are you going to be placing the print button on the master page? or do you only want it on a single page?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900