here are the page html codes -
<span onclick="javascript:printPartOfPage('Div2')">Print</span>
<div id="Div2" style="width:1024px;">
<asp:Label ID="ScInfo" runat="server" Font-Size="10pt" /><br />
<asp:Label ID="dataPreviewLabel" Font-Size="8pt" runat="server" />
</div>
and the javascript function is as follows -
<script type="text/javascript">
function printPartOfPage(elementId) {
var printContent = document.getElementById(elementId);
var windowUrl = 'about:blank';
var date = new Date();
var windowName = 'Print' + date.getTime();
var printWin = window.open(windowUrl, windowName, 'width=1024pt');
printWin.document.write(printContent.innerHTML);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
</script>
here Div2 div holds the data.you can place any data control like
GridView and populate in page load event.in the above code
when Print text clicked it calls the javascript function
printPartOfPage('Div2') by supplying the data div as a parameter
to be printed