asp.net分页控件实例源码
2013-04-25 08:59
543 查看
DataSet ds;
SqlDataAdapter dr;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AspNetPager1.AlwaysShow = true;
AspNetPager1.PageSize = 1;
AspNetPager1.RecordCount = Convert.ToInt32(DBClass.ExecuteScalar("select count(*) from StudentsWenDaTi where StudentsID = @StudentsID", new SqlParameter("StudentsID", Request.QueryString["id"]))); //数据库中有多少条记录
RepeaterDataBind();
}
}
private void RepeaterDataBind()
{
string strsql = string.Format("select * from StudentsWenDaTi where StudentsID='{0}'", Request.QueryString["id"]);
string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["StrCon"].ToString();
SqlConnection con = new SqlConnection(strconn);
con.Open();
dr = new SqlDataAdapter(strsql ,con);
ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Article");
this.DataList1.DataSource = ds.Tables["Article"];
this.DataList1.DataBind();
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
//分页
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
RepeaterDataBind();
}
SqlDataAdapter dr;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AspNetPager1.AlwaysShow = true;
AspNetPager1.PageSize = 1;
AspNetPager1.RecordCount = Convert.ToInt32(DBClass.ExecuteScalar("select count(*) from StudentsWenDaTi where StudentsID = @StudentsID", new SqlParameter("StudentsID", Request.QueryString["id"]))); //数据库中有多少条记录
RepeaterDataBind();
}
}
private void RepeaterDataBind()
{
string strsql = string.Format("select * from StudentsWenDaTi where StudentsID='{0}'", Request.QueryString["id"]);
string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["StrCon"].ToString();
SqlConnection con = new SqlConnection(strconn);
con.Open();
dr = new SqlDataAdapter(strsql ,con);
ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Article");
this.DataList1.DataSource = ds.Tables["Article"];
this.DataList1.DataBind();
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
//分页
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
RepeaterDataBind();
}
相关文章推荐
- ASP.Net 分页控件源码
- [原]ASP.NET(C#)Repeater分页控件(含源码)
- ASP.Net 分页控件源码
- asp.net分页控件使用详解【附实例下载】
- ASP.NET MVC 3.0(十九): MVC 3.0 实例之使用开源控件实现表格排序和分页
- asp.net分页控件使用详解【附实例下载】
- 我要学ASP.NET MVC 3.0(十九): MVC 3.0 实例之使用开源控件实现表格排序和分页
- asp.net Repeater分页实例(PageDataSource的使用)
- ASP.NET jQuery 实例15 通过控件CustomValidator验证CheckBoxList
- Asp.Net Web控件 (五)(可分页Repeater的使用)
- 最好的日历控件(ASP.NET),附源码,超酷,兼容IE、FIREFOX浏览器
- 用DataList控件和ObjectDataSource在ASP.NET 2.0中实现高效能数据分页
- 我学习的自定义ASP.NET分页控件
- 打造通用ASP.NET数据分页控件
- .NET、ASP.NET控件及源码大汇总
- 推荐功能齐全的Asp.net MVC 分页控件!
- asp.net html控件的File控件实现多文件上传实例分享
- Asp.net中SQL/Oracle通用分页控件
- 分享一个asp.net pager分页控件
- asp.net自制分页页码条控件