asp.net _AsoNetPager.dll 分页控件讲解 适合新手
来源:互联网 发布:淘宝高质量客户抓取 编辑:程序博客网 时间:2024/06/05 22:34
首先在网站里的 在工具栏里 反键 选择项 浏览 找到此 AsoNetPager.dll 添加此dll-->ok!
用Repeater作为显示数据
<ItemTemplate>
<!--显示自己需要的数据 DataList-->
<%# Eval("Title")%>
<br />
<hr />
</ItemTemplate>
把刚刚添加的控件 拖到页面中
选择此控件 属性--> 事件--> 双击 PageChinging 事件
前台ok!
后台
在Dbhelper类里写2方法
/// <summary>
/// 返回首行首列
/// </summary>
/// <param name="sql">查询表里一共有多少行数据</param>
/// <returns></returns>
public static int ExcuScalar(string sql ) {
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connectionStrings"].ToString());
SqlCommand cmd = new SqlCommand(sql,con);
con.Open();
cmd.CommandText = sql;
int i = (int)cmd.ExecuteScalar();
con.Close();
return i;
}
/// <summary>
/// 绑定数据
/// </summary>
/// <param name="sql">查询表的sql语句</param>
/// <param name="PageSize">1页多少行数据</param>
/// <param name="CurrentPageIndex">当前页数</param>
/// <returns></returns>
public static DataSet ReDataSetBind(string sql, int PageSize, int CurrentPageIndex)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connectionStrings"].ToString());
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds, PageSize * (CurrentPageIndex - 1), PageSize, "book");
return ds;
}
在页面。cs文件里写
在页面加载方法里:
{
this.AspNetPager1.AlwaysShow = true; //显示分页控件 1页也显示
this.AspNetPager1.PageSize = 10;//设置每一页多少行数据
this.AspNetPager1.RecordCount = DBhelper.ExcuScalar("select count(*) from books");
//---------------------------------------------------开始查询数据----
this.Bind();
}
private void Bind() {
string sql = "select * from Books";
DataSet ds = DBhelper.ReDataSetBind(sql, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex);
this.Repeater1.DataSource = ds.Tables[0];
this.Repeater1.DataBind();
}
在刚才双击PageChangind的 AspNetPager1_PageChanging 事件里写
{
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
this.Bind();
}
- asp.net _AsoNetPager.dll 分页控件讲解 适合新手
- Asp.Net数据控件引用AspNetPager.dll分页
- asp.net 委托用法 适合新手
- asp.net分页控件
- asp.net分页控件
- ASP.NET分页控件
- ASP.NET分页:AspNetPager.dll
- ASP.NET控件详细讲解
- asp.net自定义分页控件
- Asp.Net不用控件分页
- 一个ASP.NET分页控件
- Asp.Net 分页显示控件
- Asp.Net 分页显示控件
- ASP.NET MVC 分页控件
- Asp.Net 分页显示控件
- Asp.net MVC 分页控件
- ASP.NET分页控件示例
- asp.net中分页控件
- 使用nginx来负载均衡 本文在window与linux下配置nginx实现负载
- cxf 调用webservice的方式
- 关于Active Directory的文章
- 关于js中的rows&cells
- Android中Activity生命周期
- asp.net _AsoNetPager.dll 分页控件讲解 适合新手
- Linux备忘录:Linux常用命令+vi编辑器详解
- 程序员新招:Java与C++混合编程
- 很多命令一次输入去执行的方式
- 浅析SMC技术
- eclipse智能提示
- 计算某段代码运行时间之二(仅适用于windows)
- 使用VS2008的几个疑问
- Linux 内核驱动--多点触摸接口