GridView,Repeater分页控件:WebPager(开源)
来源:互联网 发布:apache ivy 编辑:程序博客网 时间:2024/05/21 18:36
一、特点:
可以用在母板、MS Ajax等控件嵌套的任何地方,支持GridView,Repeater等数据控件的分页。
二、属性:
1. PagerStyle: 设置分页样式(NextPrev,NumericPages)
2. ControlToPaginate: 指定要实现分页的控件ID(数据控件本身不需要进行数据绑定了,只需对WebPager进行数据绑定就行了)
3. PageSize: 获取或设置要在单页上显示的项数
4. CurrentPageIndex: 获取或设置当前页的索引
三、事件:
1. OnPageIndexChanged: 执行分页时触发的分页事件
四、源码下载
五、示例: (Repeater用法于此类似)
<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="true"
OnRowDataBound="GridView1_RowDataBound" AllowSorting="True" OnSorting="GridView1_Sorting">
<PagerSettings Visible="False" />
</asp:GridView>
<cc1:WebPager ID="WebPager1" runat="server" PagerStyle="NextPrev" ControlToPaginate="GridView1"
PageSize="5" OnPageIndexChanged="WebPager1_PageIndexChanged" />
OnRowDataBound="GridView1_RowDataBound" AllowSorting="True" OnSorting="GridView1_Sorting">
<PagerSettings Visible="False" />
</asp:GridView>
<cc1:WebPager ID="WebPager1" runat="server" PagerStyle="NextPrev" ControlToPaginate="GridView1"
PageSize="5" OnPageIndexChanged="WebPager1_PageIndexChanged" />
Page事件#region Page事件
Workflow.BLL.Workflow myBiz = new Workflow.BLL.Workflow();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetData();//重新获取操作后的数据源
BindGrid();//绑定GridView,为删除服务
}
}
#endregion
Gridview ----------------------------------------------------------#region Gridview ----------------------------------------------------------
数据绑定#region 数据绑定
/**//// <summary>
/// 获取数据源
/// </summary>
private void GetData()
{
this.DataSource = myBiz.GetFlowDoing(Framework.Globals.CurrentUser.UserID).Tables[0];
}
/**//// <summary>
/// 初始化绑定
/// </summary>
private void BindGrid()
{
WebPager1.DataSource = this.DataSource;
WebPager1.DataBind();
}
#endregion
排序#region 排序
/**//// <summary>
/// 排序
/// </summary>
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
string sortDirection = "";
string sortExpression = e.SortExpression;
if (this.Sort_Direction == SortDirection.Ascending)
{
this.Sort_Direction = SortDirection.Descending;
sortDirection = "DESC";
}
else
{
this.Sort_Direction = SortDirection.Ascending;
sortDirection = "ASC";
}
DataView Source = new DataView(this.DataSource);
Source.Sort = e.SortExpression + " " + sortDirection;
//GridView1.DataSource = Source;//不能再用此绑定,否则影响排序后的分页。
//GridView1.DataBind();
this.DataSource = Source.ToTable();//重新设置数据源,绑定
BindGrid();
}
#endregion
分页#region 分页
protected void WebPager1_PageIndexChanged(object sender, wf.WebPager.PageChangedEventArgs e)
{
WebPager1.CurrentPageIndex = e.NewPageIndex;
WebPager1.DataSource = this.DataSource;
WebPager1.DataBind();
}
#endregion
#endregion
Workflow.BLL.Workflow myBiz = new Workflow.BLL.Workflow();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetData();//重新获取操作后的数据源
BindGrid();//绑定GridView,为删除服务
}
}
#endregion
Gridview ----------------------------------------------------------#region Gridview ----------------------------------------------------------
数据绑定#region 数据绑定
/**//// <summary>
/// 获取数据源
/// </summary>
private void GetData()
{
this.DataSource = myBiz.GetFlowDoing(Framework.Globals.CurrentUser.UserID).Tables[0];
}
/**//// <summary>
/// 初始化绑定
/// </summary>
private void BindGrid()
{
WebPager1.DataSource = this.DataSource;
WebPager1.DataBind();
}
#endregion
排序#region 排序
/**//// <summary>
/// 排序
/// </summary>
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
string sortDirection = "";
string sortExpression = e.SortExpression;
if (this.Sort_Direction == SortDirection.Ascending)
{
this.Sort_Direction = SortDirection.Descending;
sortDirection = "DESC";
}
else
{
this.Sort_Direction = SortDirection.Ascending;
sortDirection = "ASC";
}
DataView Source = new DataView(this.DataSource);
Source.Sort = e.SortExpression + " " + sortDirection;
//GridView1.DataSource = Source;//不能再用此绑定,否则影响排序后的分页。
//GridView1.DataBind();
this.DataSource = Source.ToTable();//重新设置数据源,绑定
BindGrid();
}
#endregion
分页#region 分页
protected void WebPager1_PageIndexChanged(object sender, wf.WebPager.PageChangedEventArgs e)
{
WebPager1.CurrentPageIndex = e.NewPageIndex;
WebPager1.DataSource = this.DataSource;
WebPager1.DataBind();
}
#endregion
#endregion
- GridView,Repeater分页控件:WebPager(开源)
- GridView,Repeater分页控件:WebPager(开源)
- GridView,Repeater分页控件:WebPager(开源)
- AspNetPager.dll分页控件绑定gridview,datalist,repeater
- Repeater控件分页例子
- Repeater控件分页例子
- Repeater控件分页例子
- Repeater控件分页
- Repeater控件分页
- Repeater控件分页例子
- Repeater控件实现分页
- Repeater控件分页例子
- Repeater控件分页例子
- Repeater控件分页
- Repeater控件自定义分页
- Repeater控件分页例子
- repeater控件分页
- repeater控件实现分页
- 删除Windows Installer Cache造成的软件无法删除的修复方法(摘)
- HDOJ1002
- CakePHP 使用 Bake 代码生成器
- Oracle 9i Exception: ORA-01504 错误解决方案
- 关于hashtable装换成datatable的代码
- GridView,Repeater分页控件:WebPager(开源)
- PKU 2750 Potted Flower 解题报告
- C语言位运算
- 关于Debug和Release之本质区别的讨论(zt)
- 升级版人生
- SQL Server 常用函数和日期操作
- WIN 2003下实现网页播放FLV的功能,添加flv对应的mime
- Ext JS 学习(2) Ext.Panel 组件的使用
- 提交按钮点击后变灰色(不能再点),页面处理完毕后变为正常,避免重复提交