Enable Printing content of GridView in ASP.NET 2.0

First Option:
The javascript is from this Site
To enable directly print the contents of the gridview.
Just add this line of code on form load
<Button Name>.Attributes.Add(“onclick”, “javascript:CallPrint(‘PrintGrid’)”);

Add this javascript at the bottom of the page designer.
<script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open(”,”,’letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0′);
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>

Second Option:
To Enable to print the contents of a grid to a report
Just add this line of code on form load
<Button Name>.Attributes.Add(“onclick”, “window.open(‘” + “<Web Form Name>.aspx” + “‘)”);
Pass the list to the report.

Ask Medel Antiporta for the second option.

Advertisements
This entry was posted in ASP.NET 2. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s