/// <summary> /// 绑定数据源事件 /// </summary> private void GetRoles(string keyword) { var dt = bll.GetRolesListByTitle(keyword); PagedDataSource psd = new PagedDataSource(); //实例化 分页的数据源方法 psd.DataSource = dt; //绑定数据源 psd.AllowPaging = true; //是否分页 psd.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; // PagedDataSource 当中页码是从0开始的,和我们的数组下标一样 psd.PageSize = AspNetPager1.PageSize; //设定每页展示的数据条数 AspNetPager1.RecordCount = dt.Count; //给分页插件设定数据的总条数 this.RepRolesList.DataSource = psd; //给Repeater控件传入数据源,这个数据源是我们自己设定的分页的数据源 this.RepRolesList.DataBind(); //实现Repeater数据绑定 }