1. Print a DataGrid Alone from an ASP.NET Web Page
URL :
http://www.devx.com/tips/Tip/27626
Ever wanted to print a DataGrid alone from an ASP.NET Web page? Put an <asp:DataGrid> tag inside the tag does the trick. Here are the steps involved:
Enclose the <asp:datagrid></asp:datagrid> tag inside the <div></div> tag.
Write a JavaScript function which takes care of printing the content from <div> tag.
Here's an example:
<script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>
<div id="divPrint">
<asp:datagrid>
.....
.....
.....
</asp:datagrid>
</div>
<asp:button ID="btnPrint" onClick="javascript
:CallPrint('divPrint');" Runat=Server />
2.
http://www.codeproject.com/useritems/Print_Grid.asp