AspNetPager 三层分页
来源:互联网 发布:php 怎么去掉html标签 编辑:程序博客网 时间:2024/04/28 08:16
.aspx
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True"
FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
onpagechanged="AspNetPager1_PageChanged"
onpagechanging="AspNetPager1_PageChanging" PageSize="5" PrevPageText="上一页"
ShowInputBox="Always" UrlPaging="True" CustomInfoHTML="共 <font color="red">%RecordCount%</font> 条记录 当前 <font color="red">%CurrentPageIndex%/%PageCount%</font> 页"
ShowCustomInfoSection="Left">
CustomInfoHTML="共 <font color="red">%RecordCount%</font> 条记录 当前 <font color="red">%CurrentPageIndex%/%PageCount%</font> 页"
.aspx.cs
private void BindDatabale()
{
int iPageIndex = AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1);
int iPageSize = AspNetPager1.PageSize;
DataSet dt = NewsServer.GetDataSet(iPageIndex,iPageSize);
//lblValue.Text = dt.Rows.Count.ToString();
lblValue.Text = dt.Tables.Count.ToString();
AspNetPager1.RecordCount = Convert.ToInt32(NewsServer.GetCount().ToString());
//PagedDataSource pds = new PagedDataSource();
//pds.DataSource = dt.Tables;
//pds.PageSize = AspNetPager1.PageSize ;
//pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
DataList1.DataSource = dt;
this.DataList1.DataBind();
}
--- 第二中方式 直接查询出所有的数据
private void BindHot()
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = bll.GetInfoHot().DefaultView;
this.AspNetPager2.RecordCount = pds.Count;
pds.AllowPaging = true;
pds.PageSize = this.AspNetPager2.PageSize;
pds.CurrentPageIndex = this.AspNetPager2.CurrentPageIndex - 1;
DataList1.DataSource = pds;
DataList1.DataBind();
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindDatabale();
}
.cs
public static DataSet GetDataSet(int pageIndex, int pageSize)
{
string strSql = "select * from News";
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
SqlCommand cmd = new SqlCommand(strSql, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, pageIndex, pageSize, "News");
return ds;
}
sql:
string strSql = "select top " + pager.PageSize + " * from tb where id not in (select top " + (pager.CurrentPageIndex - 1) * pager.PageSize + " id from tb order by id DESC) order by id DESC";
使用手动sql分页
select top (@pageNum) * from table where ID
not in(select top (@pageNum*(@pageNo-1)) ID from table order by WriteTime desc)
order by WriteTime desc
使用aspnetPager的sql语句:
pageNo //显示过的数据
pageNum//显示多少条数据
select top (@pageNum) * from table where ID
not in(select top (@page
使用手动sql分页
select top (@pageNum) * from table where ID
not in(select top (@pageNum*(@pageNo-1)) ID from table order by WriteTime desc)
order by WriteTime desc
使用aspnetPager的sql语句:
pageNo //显示过的数据
pageNum//显示多少条数据
select top (@pageNum) * from table where ID
not in(select top (@pageNo) ID from table order by WriteTime desc)
order by WriteTime descNo) ID from table order by WriteTime desc)
order by WriteTime desc
- AspNetPager 三层分页
- 结合aspnetpager控件和三层的sql语句的分页
- AspNetPager分页
- AspNetPager分页
- AspNetPager分页
- AspNetPager 分页
- AspNetPager 分页
- aspnetpager分页
- AspNetPager分页
- aspnetpager分页
- AspNetPager分页
- AspNetPager 分页
- 三层架构+存储过程后台分页+AspNetPager前台分页的经典例子
- AspNetPager分页控件
- AspNetPager分页控件
- AspNetPager分页控件
- AspNetPager分页简单应用
- AspNetPager分页控件
- 从FCN到DeepLab
- 通过java读取HDFS的数据
- IList转换Datatable
- Web Glossary WEB词汇表
- CodeForces 629A Far Relative’s Birthday Cake(组合数,水题)
- AspNetPager 三层分页
- sql 日期过期判断
- useCapture:true与flase的表现区别 事件的冒泡与捕获
- JS Enter建设置
- 弹出层显示
- Spark排错与优化
- 部署安装
- IE兼容上传图片预览
- 开博纪念