How to print in a WebControls.DataGrid?

Discussion in 'ASP .Net Web Controls' started by F. Javier Sáez, May 11, 2004.

  1. Hi everybody!

    I need to print the content of a DataGrid placed in a webform but I don't
    know how to do that.

    Can anybody help me???

    Please, attach code example if posible!

    Thanks in advance!!!
     
    F. Javier Sáez, May 11, 2004
    #1
    1. Advertising

  2. Scott Mitchell [MVP], May 11, 2004
    #2
    1. Advertising

  3. F. Javier Sáez

    hrothenb Guest

    You can print the control's contents using javascript. Open another window with whatever you want to print on it and with a print link on it. Add the script into the head section of the ASP.Net page on the HTML view tab in design view.

    <script language =javascript>
    function PrintResults()
    {
    var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";

    sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";


    var sWinHTML = document.getElementById('MyTextBox').innerHTML;

    var winprint=window.open("","",sOption);
    winprint.document.open();

    winprint.document.write("<HTML><Head></Head><Body>")
    winprint.document.write("<a href='javascript:;' onClick='window.print();return false'>Print This Page.</a><br>");
    winprint.document.write(sWinHTML);
    winprint.document.write("</Body></HTML>")
    winprint.document.close();
    winprint.focus();
    }
    </script>




    "F. Javier Sáez" wrote:

    > Hi everybody!
    >
    > I need to print the content of a DataGrid placed in a webform but I don't
    > know how to do that.
    >
    > Can anybody help me???
    >
    > Please, attach code example if posible!
    >
    > Thanks in advance!!!
    >
    >
    >
     
    hrothenb, Jun 10, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Evanchik
    Replies:
    3
    Views:
    593
    Yan-Hong Huang[MSFT]
    Jul 30, 2003
  2. EMW
    Replies:
    5
    Views:
    337
  3. keto
    Replies:
    0
    Views:
    1,045
  4. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    400
    David Cournapeau
    Dec 30, 2008
  5. alex

    Print preview bug in IE7 with MS WebControls

    alex, Dec 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    118
Loading...

Share This Page