在asp.net中使用转发器控件时,如何在每个页面上打印页眉? [英] How to print a header on each and every page .when using a repeater control in asp.net ?

查看:48
本文介绍了在asp.net中使用转发器控件时,如何在每个页面上打印页眉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试打印绑定到中继器控件的数据.我使用以下java脚本方法进行打印:

Hi every one,

I''m trying to print data which is binded to a repeater control. I used the following java script method to print:

function CallPrint() {         
    window.print();
}



我想要的是每个页面上的标头(在每个分页符之后).我尝试了很多方法,但是我做不到.任何帮助都非常欢迎,在此先感谢...

我的完整代码如下:



What I would like is a header on each and every page (after each page break). I tried in many ways but i couldn''t get it. Any help is most welcome and thanks in advance...

My complete code is below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RepeaterControl.aspx.cs" Inherits="RepeaterControl" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<style type="text/css"> 
    .pageBreak{page-break-after:always;} 
 </style> 


    <script type="text/javascript">
    function CallPrint() {
           //document.getElementById('gridID').style.display='block';

            window.print();
           // document.getElementById('gridID').style.display = 'none';
        }
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:Repeater ID="Repeater1" runat="server" 

            onitemdatabound="Repeater1_ItemDataBound">
      
        <HeaderTemplate>
         <table class="pageBreak">
            <tr bgcolor="#e8e8e8">
                <td>
                    CustomerID
                </td>
                <td>CustomerName</td>
                <td>ContactName </td>
                <td> Address </td>
            </tr>
        </HeaderTemplate>
        
        <itemtemplate>
            <tr>
                <td>
                    <asp:Label runat="server" Text='<% Eval("CustomerID") %>' >
                    <%# DataBinder.Eval(Container,"DataItem.CustomerID") %>
                 </td>
                 <td>
                     <%#((DataRowView)Container.DataItem)["CompanyName"]%>
                 </td>
                 <td>
                     <%#((DataRowView)Container.DataItem)["ContactName"]%>  
                 </td>
                 <td>
                     <%# DataBinder.Eval(Container, "DataItem.Address")%>
                 </td>
            </tr>
       </itemtemplate>
       <!-- <alternatingitemtemplate>
          <tr bgcolor="#e8e8e8">>
        <td>
        <%# DataBinder.Eval(Container,"DataItem.ID") %>
        </td>
        <td>
        <%#((DataRowView)Container.DataItem)["Name"]%>
        </td>
        <td><%#((DataRowView)Container.DataItem)["Designation"]%>  </td>
        <td>
         <%# DataBinder.Eval(Container, "DataItem.Date")%>
        </td>
        </tr>
        
        
            </alternatingitemtemplate>-->
            <footertemplate>
            </footertemplate>
        </table>
        
        
        <asp:Button ID="btn1" runat="server" Text="Print" 

            OnClientClick="Javascript:CallPrint()" onclick="btn1_Click" />
    </div>
    </form>
</body>
</html>

推荐答案

得到它,如果您正在寻找解决方案,请通过以下链接
http://maheshpashamdotnet.blogspot.in/2012_04_01_archive.html [
got it please go through the following link if you are looking for solution
http://maheshpashamdotnet.blogspot.in/2012_04_01_archive.html[^]


这篇关于在asp.net中使用转发器控件时,如何在每个页面上打印页眉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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