Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to give print option to datagrid?

How to give print option to datagrid?

Scheduled Pinned Locked Moved ASP.NET
questiontutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gowtham Sen
    wrote on last edited by
    #1

    Hi, I have a datagrid in my application. I would like provide an option, whenever that event is fired, the data in datagrid should be printed. How can I do this? could you please give some idea. Thanks and Regards Gowtham Sen

    G 1 Reply Last reply
    0
    • G Gowtham Sen

      Hi, I have a datagrid in my application. I would like provide an option, whenever that event is fired, the data in datagrid should be printed. How can I do this? could you please give some idea. Thanks and Regards Gowtham Sen

      G Offline
      G Offline
      goyal manish
      wrote on last edited by
      #2

      put the datagrid in a div and when click on the button call a javascript function which will print the grid. function will be as following : function CallPrint() { var prtContent = document.getElementById('Test1'); var WinPrint = window.open("Print.aspx",'Print','scrollbars=yes,resizable=yes,width=900,height=600,top=200,left=200'); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); prtContent.innerHTML=strOldOne; return false; } here 'Test1' is teh id of div in which grid wil be there. and print.aspx will be new window which wil be open as a print preview.

      G 1 Reply Last reply
      0
      • G goyal manish

        put the datagrid in a div and when click on the button call a javascript function which will print the grid. function will be as following : function CallPrint() { var prtContent = document.getElementById('Test1'); var WinPrint = window.open("Print.aspx",'Print','scrollbars=yes,resizable=yes,width=900,height=600,top=200,left=200'); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); prtContent.innerHTML=strOldOne; return false; } here 'Test1' is teh id of div in which grid wil be there. and print.aspx will be new window which wil be open as a print preview.

        G Offline
        G Offline
        Gowtham Sen
        wrote on last edited by
        #3

        Hai Goyal Manish, Thanks a lot. Its working very good. I was surprised very much. If you don't mind can you explain the code line by line briefly. Thanks and Regards Gowtham Sen.

        G 1 Reply Last reply
        0
        • G Gowtham Sen

          Hai Goyal Manish, Thanks a lot. Its working very good. I was surprised very much. If you don't mind can you explain the code line by line briefly. Thanks and Regards Gowtham Sen.

          G Offline
          G Offline
          Gowtham Sen
          wrote on last edited by
          #4

          Dear Manish, I have one problem that, the datagrid is in the middle of the page. So while I am viewing in the print view, more space is wasted at the header. can we edit the print view page and then print as we want. Is it possible? Another thing is, how to zoom the page. How can we set this option fot it? Could you please give me some idea. Thanks and Regards Gowtham Sen

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups