首页 > 安全资讯 >

实例repeater 分页、表头不动、添加列序号

12-07-31

前台代码:<head runat="server"> <title></title> <link href="css/IE.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .fixHeaderStyle { PADDING-RIGHT: 0px; PADDING-LEFT...

 前台代码:

<head runat="server">
    <title></title>
    <link href="css/IE.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
       .fixHeaderStyle
        { PADDING-RIGHT: 0px;
        PADDING-LEFT: 0px;
        FONT-WEIGHT: bold;
        FONT-SIZE: 12px;
        VERTICAL-ALIGN: middle;
        LINE-HEIGHT: 20px;
        FONT-FAMILY: "Arial" , "Helvetica" , "sans-serif";
        POSITION: relative;
        TOP: expression(this.offsetParent.scrollTop-2);
        Z-INDEX: 5 ; HEIGHT: 26px; BACKGROUND-COLOR: #f0f0e8;
        TEXT-ALIGN: center; TEXT-DECORATION: none;
        ext-transform: capitalize ;

        }
        .scrollColThead {position: relative;
top: expression(this.parentElement.parentElement
.parentElement.scrollTop);
z-index:2;}

        .hlink
        {
        height:25px;width:40px;color:Blue;font-size:15px;
            }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div >
        <asp:Repeater ID="Repeater1" runat="server"
            onitemdatabound="Repeater1_ItemDataBound">
        <HeaderTemplate>
        <div style="">
        <table width="340%" id="tblResult" bgcolor="CornflowerBlue"  cellpadding=1 cellspacing=1 >
       <%-- <tr style="position:relative; top:expression(this.offsetParent.scrollTop);">
--%>
        <tr  class = "fixHeaderStyle">
        <td class="clsHeader">NO.</td>
        <td class="clsHeader">Type</td>
        <td class="clsHeader">ETD Date</td>
        <td class="clsHeader">MB/L#</td>
        <td class="clsHeader"> HB/L#</td>
        <td class="clsHeader">Party Type</td>
        <td class="clsHeader">Code</td>
        <td class="clsHeader">Name</td>
        <td class="clsHeader">Curr</td>
<%--        <td class="clsHeader">A/R</td>
        <td class="clsHeader">A/P </td>--%>
        <td class="clsHeader">发票号</td>
        <td class="clsHeader">开票日期</td>
        <td class="clsHeader">JobID</td>
        <td class="clsHeader">开票人</td>
        <td class="clsHeader">Sales</td>
        <td class="clsHeader">R/O</td>
        <td class="clsHeader">核销单</td>
        <td class="clsHeader">Flight#/Date</td>
        <td class="clsHeader">ETA</td>
        <td class="clsHeader">Pay Terms</td>
        <td class="clsHeader">Agreement No.</td>
        <td class="clsHeader">No.</td>
        <td class="clsHeader">过账人</td>
        <td class="clsHeader">过账日期</td>
        <td class="clsHeader">过账凭证</td>
        <td class="clsHeader">记账人</td>
        <td class="clsHeader">记账日期</td>
        <td class="clsHeader">记账凭证</td>
        <td class="clsHeader">对账人</td>
        <td class="clsHeader">对账日期</td>
        <td class="clsHeader">对账凭证</td>
        <td class="clsHeader">签收人</td>
        <td class="clsHeader">签收日期</td>
        <td class="clsHeader">签收凭证</td>
        <td class="clsHeader">销账人</td>   

        <td class="clsHeader">销账日期</td>
        <td class="clsHeader">销账凭证</td>
        <td class="clsHeader">作废人</td>
        <td class="clsHeader">作废日期</td>
        <td class="clsHeader">LockBy</td>
        <td class="clsHeader">P/L No.</td>
        <td class="clsHeader">MANIFEST#</td>
        <td class="clsHeader">制单日期</td>
        <td class="clsHeader">制单人</td>
        </tr>
        </HeaderTemplate>
        <ItemTemplate>
        <tr style="background-color:White;">
        <td>
        <%= inumber+ (CurPage-1)*500 %>
        <% inumber++; %>
        </td>
        <td><%# DataBinder.Eval(Container.DataItem, "BILL_TYPE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ETD_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "MAWB_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AWB_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PARTY_TYPE_NAME")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PARTY_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PARTY_NAME")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CURRENCY")%></td>
<%--        <td><%# DataBinder.Eval(Container.DataItem, "AR")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AP")%></td>--%>
        <td><%# DataBinder.Eval(Container.DataItem, "TAXINV_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "TAXINV_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "JOBID")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "TAXINV_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "SALESMAN_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RO_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "TR_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "FIRST_FLIGHT_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "FIRST_FLIGHT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AE_AGREEMENT_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AE_PAYTERMS_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "DN_CN_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ISSUED_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ISSUED_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ISSUED_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "POSTACCT_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "POSTACCT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "POSTACCT_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CHECKED_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CHECKED_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CHECKED_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RECEIPT_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RECEIPT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RECEIPT_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CANCELACCT_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CANCELACCT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CANCELACCT_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "VOID_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "VOID_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "LOCKED_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PL_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "MANIFEST_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "LASTUPDATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "MODIFIED_BY")%></td>      
        </tr>
        </ItemTemplate>
        <AlternatingItemTemplate >
        <tr >
        <td>
        <%= inumber+ (CurPage-1)*500 %>
        <% inumber++; %>
        </td>
        <td><%# DataBinder.Eval(Container.DataItem, "BILL_TYPE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ETD_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "MAWB_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AWB_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PARTY_TYPE_NAME")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PARTY_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PARTY_NAME")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CURRENCY")%></td>
<%--        <td><%# DataBinder.Eval(Container.DataItem, "AR")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AP")%></td>--%>
        <td><%# DataBinder.Eval(Container.DataItem, "TAXINV_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "TAXINV_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "JOBID")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "TAXINV_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "SALESMAN_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RO_CODE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "TR_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "FIRST_FLIGHT_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "FIRST_FLIGHT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "AE_AGREEMENT_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "DN_CN_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ISSUED_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ISSUED_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "ISSUED_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "POSTACCT_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "POSTACCT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "POSTACCT_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CHECKED_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CHECKED_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CHECKED_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RECEIPT_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RECEIPT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "RECEIPT_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CANCELACCT_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CANCELACCT_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "CANCELACCT_VOUCHER")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "VOID_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "VOID_DATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "LOCKED_BY")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "PL_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "MANIFEST_NUM")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "LASTUPDATE")%></td>
        <td><%# DataBinder.Eval(Container.DataItem, "MODIFIED_BY")%></td>
      
        </tr>
        </AlternatingItemTemplate>
        <FooterTemplate>
        </table>
        </div>
        </FooterTemplate>
        </asp:Repeater>
        <div>
            <asp:Label ID="lblCurrentPage" runat="server" ></asp:Label>
           
            <asp:HyperLink class="" style="background-color:;" ID="lnkFrist" runat="server"><span class="hlink">首页</span></asp:HyperLink>
            <asp:HyperLink class="" style="background-color:;" ID="lnkPrev" runat="server"><span class="hlink">上一页</span></asp:HyperLink>
            <asp:HyperLink class="" style="background-color:;" ID="lnkNext" runat="server"><span class="hlink">下一页</span></asp:HyperLink>
            <asp:HyperLink class="" style="background-color:;" ID="lnkEnd" runat="server"><span class="hlink">尾页</span></asp:HyperLink>

        </div>
    </div>
    </form>
</body>
</html>

 

后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace DNoteCNote
{
    public partial class repeaterGet2 : System.Web.UI.Page
    {
        public int inumber = 1;
        public int CurPage;
        PagedDataSource PDS = new PagedDataSource();
        private string constr=@"data source=.\mssqlserver1;database=ATP_ATR;uid=sa;pwd=123456";
        private string strsql="";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }

        }
        private void bind()
        {
            int TotalCount = 0;
            int TotalPage = 1;
             SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            strsql = "select  * from VIEW_RPT_AE_DNOTE_CNOTE";
            SqlDataAdapter adapter = new SqlDataAdapter(strsql,conn);
            DataSet ds = new DataSet();
            adapter.Fill(ds,"dnotecnote");
            DataView dv = ds.Tables[0].DefaultView;
            TotalCount=dv.Count;
            PDS.DataSource = dv;
            conn.Close();
            PDS.AllowPaging =true;
            PDS.PageSize = 500;
           
            if (Request.QueryString["Page"] != null)
            {
                CurPage = Convert.ToInt32(Request.QueryString["Page"]);

            }
            else
                CurPage = 1;
           
            if (TotalCount == 0)
            {
                TotalPage = 1;

            }
            else
            {
                if (TotalCount % PDS.PageSize == 0)
                    TotalPage = TotalCount / PDS.PageSize;
                else www.2cto.com
                    TotalPage = TotalCount / PDS.PageSize + 1;

            }
            PDS.CurrentPageIndex = CurPage - 1;
            lblCurrentPage.Text = "共" + TotalCount.ToString() + "条记录 当前页:" + CurPage.ToString() + "/" + TotalPage;
            lnkFrist.NavigateUrl = Request.CurrentExecutionFilePath + "?page=1";
            if (!PDS.IsFirstPage)
                lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(CurPage - 1);
            if (!PDS.IsLastPage)
                lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
            lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + TotalPage;

            Repeater1.DataSource=PDS;
            Repeater1.DataBind();

        }

                   
    }
}

 

 


作者:liziki
相关文章
最新文章
热点推荐