关于分页 如何将aspnetpager控件的分页与datalist联系起来,意思就是如果datalist分为两页,那么点aspnetpager的第2页,然后datalist自动翻页? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 aspnetpager只是一个控件,具体的代码还得写。 using System.Data.SqlClient;DataSet ds; SqlDataAdapter dr; SqlCommand com; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库"); con.Open(); com = new SqlCommand(); com.Connection = con; com.CommandText = "select count(*) from Employees"; AspNetPager1.AlwaysShow=true; AspNetPager1.PageSize=15; AspNetPager1.RecordCount = (int)com.ExecuteScalar(); con.Close(); DataListDataBind(); } } private void DataListDataBind() { SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库"); dr = new SqlDataAdapter("select * from Employees", con); ds = new DataSet(); dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Employees"); DataList1.DataSource = ds.Tables["Employees"]; DataList1.DataBind(); } protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e) { AspNetPager1.CurrentPageIndex = e.NewPageIndex; DataListDataBind(); } 应该差不多,好像还有个问题,是不是CurrentPageIndex需要实现顶一下?或者不需要定义直接就可以用? 没明白CurrentPageIndex需要实现顶一下是什么意思aspnetpager控件的那个DLL添加了就能用了啊代码已经很详细了 表 字段什么的改下就行了 谢谢了,分我全给您了,如此简单的程序,我想了2小时,原因是不知道FILL的参数居然有中间的俩个哈哈! 他 这个是全取出来在分页的啊你可以取前15条 点第2页的时候娶16到30啊.....这样回好一些关键是分页的SQL语句 要明白 Cookie和session 批量打印物流单后,如何获取对应的物流单号? 新手请教高手!! .NET如何绑定业务对象? 散100分,超晕闷的简单问题!.net2.0框架设置问题 girdview的RowDeleted方法e.Exception如何使用 |M| 如何用最科学的方面来查询一个DataView中 Age=12的记录数 和Age=13的记录数 关于自定义控件的输出机制,高分求教 能否在datagrid中显示Excel的内容? C#正常运行要.Net Framework的支持? GridView 更新问题--在线等 XmlElement与XMLNodeList的区别?
DataSet ds;
SqlDataAdapter dr;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库");
con.Open();
com = new SqlCommand();
com.Connection = con;
com.CommandText = "select count(*) from Employees";
AspNetPager1.AlwaysShow=true;
AspNetPager1.PageSize=15;
AspNetPager1.RecordCount = (int)com.ExecuteScalar();
con.Close();
DataListDataBind();
}
}
private void DataListDataBind()
{
SqlConnection con = new SqlConnection("server=.;uid=sa;database=数据库");
dr = new SqlDataAdapter("select * from Employees", con);
ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Employees");
DataList1.DataSource = ds.Tables["Employees"];
DataList1.DataBind(); } protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
DataListDataBind();
}
或者不需要定义直接就可以用?
aspnetpager控件的那个DLL添加了就能用了啊
代码已经很详细了 表 字段什么的改下就行了
如此简单的程序,我想了2小时,原因是不知道FILL的参数居然有中间的俩个哈哈!