Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my javascript code -
XML
<script type="text/javascript">
    function printGrid() {

        var gridData = document.getElementById('<%=GridView1.ClientID %>');

        var windowUrl = 'about:blank';
        //set print document name for gridview
        var uniqueName = new Date();
        var windowName = 'Print_' + uniqueName.getTime();

        var prtWindow = window.open(windowUrl, windowName,
        'left=100,top=100,right=100,bottom=100,width=700,height=500');
        prtWindow.document.write('<html><head></head>');
        prtWindow.document.write('<body style="background:none !important">');
        prtWindow.document.write(gridData.outerHTML);
        prtWindow.document.write('</body></html>');
        prtWindow.document.close();
        prtWindow.focus();
        prtWindow.print();
        prtWindow.close();
    }



    </script>





plz help how to hide 1st column in gridview..........
Posted
Updated 28-Jan-15 20:01pm
v2

Please have a look into below solution

JavaScript
<script type="text/javascript">
    function printGrid() {

        var gridData = document.getElementById('<%=GridView1.ClientID %>');

        var windowUrl = 'about:blank';
        //set print document name for gridview
        var uniqueName = new Date();
        var windowName = 'Print_' + uniqueName.getTime();
        var prtWindow = window.open(windowUrl, windowName,
        'left=100,top=100,right=100,bottom=100,width=700,height=500')

   
  
        prtWindow.document.write('<html><head></head>');
        prtWindow.document.write('<body style="background:none !important">');
        prtWindow.document.write(gridData.outerHTML);
        prtWindow.document.write('</body></html>');

       //get pop up window rows 
        var rows = prtWindow.document.getElementById('<%=GridView1.ClientID %>').rows;
        for (var i = 0; i < rows.length; i++) {
          // remove first column
            rows[i].deleteCell(0);
        }

        prtWindow.document.close();
        prtWindow.focus();
        prtWindow.print();
        prtWindow.close();
    }
 
Share this answer
 
v2
Comments
Member 10385151 29-Jan-15 2:50am    
thanks sir this code is working but next is how to false AllowPaging in this code
Rakesh Bairi 29-Jan-15 3:59am    
In Asp.Net AllowPaging is Handled from code behind
Please refer this link it might be useful to you
http://www.aspsnippets.com/Articles/Print-functionality-in-ASP.Net-GridView-control.aspx
Member 10385151 29-Jan-15 4:24am    
I NEED TO USED IN PRINT TIME IN THIS JAVASCRIPT FUNCATION
You can refer following link to hide the columns Printing only selected colums of Gridview[^]
 
Share this answer
 

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