Thursday, June 14, 2012

Print Grid View

Hi All,
         Few of my Blog Members asked me code related to Print Grid-view 



step 1:  Create  html button

<input type="button" value="Print " id="bbtnPrint" runat="Server" onclick="javascript:CallPrint('name')"  visible="false"/>

Step 2: in the div tag use  grid-view

<div id=”name”>
   <table>

   </table>
</div>

step 3:Function Call

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

</script>