0315分页控件AspNetPage

 //上午AspNetPager分页控件

DAL Repter.DataSource返回所需数据

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using WebContact.DAL;
namespace WebContact
{
   

    public partial class ContactAdmin : System.Web.UI.Page
    {

        private ContactDAL DAL = new ContactDAL();


        protected void Page_Load(object sender, EventArgs e)
        {

            //初次加载页面 绑定
            if(!IsPostBack){
               BindData();
               BindGroupList();
            }

        }

//repeater使用
        private void BindGroupList()
        {
            //把查询返回的DataTable传给Repeater
            rep_Groups.DataSource = new GroupDAL().GetGroups();
            rep_Groups.DataBind();
        }
        private void BindData()
        {

//控件获取所取数据总行
            AspNetPager1.RecordCount = DAL.GetCount();

//Repeater.DataSoure 所取DAL.getByPage(int,int) 数据填充 所需参数由分页控件提供 #

            Repeater1.DataSource = DAL.GetByPage(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);
            Repeater1.DataBind();

        }

//分页控件的页面更改事件中调用BindData()

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}

/页面代码

 

分页控件 添加控件指定ID&事件名

<webdiyer:AspNetPager ID="AspNetPager1" runat="server"
                onpagechanged="AspNetPager1_PageChanged">
            </webdiyer:AspNetPager>

--------------------------------

Repeater

 

 <asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate>

//表头
              </HeaderTemplate>
        <ItemTemplate>
              <tr>
        <td><%#Eval("ContactId") %></td>
        <td><%#Eval("Name") %></td>
        遍历输出表
      </tr>
        </ItemTemplate>
        <FooterTemplate>


                </FooterTemplate>
        </asp:Repeater>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值