打印Gridview数据 [英] print Gridview data

查看:64
本文介绍了打印Gridview数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

script:window.print()从gridview打印数据
但它会在论文的网页上显示整个数据

script:window.print() to print the data from gridview
but It displays entire data on the web page in the paper

Is it possible to print gridview data only?

推荐答案

您可以在代码后面编写与打印相关的代码,然后将其注入页面:
如何在ASP.NET 2.0中打印 [
Either you can write your print related code in code behind and then inject it into the page:
How to Print in ASP.NET 2.0[^]

OR using JavaScript directly on the page itself, like:
function CallPrint()
{
  var printContent = document.getElementById('<%= pnlToPrint.ClientID %>');
  var printWindow = window.open("", "Print Panel", ‘left=50000,top=50000,width=0,height=0′);
  printWindow.document.write(prtContent.innerHTML);
  printWindow.document.close();
  printWindow.focus();
  printWindow.print();
  printWindow.close();
}


<asp: Panel runat="server" id="pnlToPrint" >
  <table>
    <tr>
      <td>
         Your data
      </td>
    </tr>
  </table>
</asp: Panel>

<input type="button" value="Print"  onclick="CallPrint();" />


上面的代码仅打印面板内的内容-可以是网格,甚至可以是标签.


Above code prints just the content inside the panel - can be a grid or even just a label.


这篇关于打印Gridview数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆