How to print in a WebControls.DataGrid?

F

F. Javier Sáez

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!!!
 
S

Scott Mitchell [MVP]

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

You can insert client-side code to do this, something like:

<input type="button" value="Print" onclick="javascript:window.print();">

For more information, see:
http://aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=164

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
H

hrothenb

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top