private void TxtShow(Repeater dlt)
{
string temp = this.cont.Text;
int cont = Convert.ToInt32(temp);
SqlConnection con = DBHelper.Conn();
string sql = "select * from LeaveWord";
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds,"LeaveWord");
System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
ps.DataSource = ds.Tables[0].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 2;
ps.CurrentPageIndex = cont - 1;
UP.Enabled = true;
Down.Enabled = true;
if (cont == 1)
{
UP.Enabled = false;
Down.Enabled = true;
}
if (cont == ps.PageCount)
{
UP.Enabled = true;
Down.Enabled = false;
}
dlt.DataSource = ds;
dlt.DataBind();
}
它全部都显示出来了,分页都没有效果。我找不出问题来,帮帮忙看一下吧!说详细一点
初始cont = "1"
{
string temp = this.cont.Text;
int cont = Convert.ToInt32(temp);
SqlConnection con = DBHelper.Conn();
string sql = "select * from LeaveWord";
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds,"LeaveWord");
System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
ps.DataSource = ds.Tables[0].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 2;
ps.CurrentPageIndex = cont - 1;
UP.Enabled = true;
Down.Enabled = true;
if (cont == 1)
{
UP.Enabled = false;
Down.Enabled = true;
}
if (cont == ps.PageCount)
{
UP.Enabled = true;
Down.Enabled = false;
}
dlt.DataSource = ds;
dlt.DataBind();
}
它全部都显示出来了,分页都没有效果。我找不出问题来,帮帮忙看一下吧!说详细一点
初始cont = "1"
解决方案 »
- Dictionary<string, object>转换报错
- System.Data.OleDb.OleDbException: 文件名无效。
- 关于在DataGrid里添加一个全选按钮的问题
- 今天 开发网站遇到一些特别奇怪的问题
- <ASP:TABLE>的BORDERCORLOR问题
- datagrid不能读取表中数据
- 关于Session失效 急救!
- asp.net vs2008,gridview导出excel时如何取消其中的超链接?注意:不是模板列
- 讨论:ASP.NET多项目管理及代码重用问题
- 请教:这样调用sql server的存储过程为什么有问题
- asp.net中图片不能显示问题
- 如何实现一个b/s网上订餐系统购物车代码
如果数据量不大,可以用自带的分页功能
如果数据量大,可以用第三方,也可以用vs自带的objectdatasource 实现三层分页。
PagedDataSource objPage=new PagedDataSource();
objPage.DataSource=ds.Tables["user"].DefaultView;
objPage.AllowPaging=true;
objPage.PageSize=6;
int CurPage;
if(Request.QueryString["Page"]!=null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPage.CurrentPageIndex=CurPage-1;
this.lblCurPage.Text="当前页:第"+CurPage.ToString()+"页";
this.DataList1.DataSource=objPage;
this.DataList1.DataBind(); aspnetpager分页控件
或者引用第三方的也行 Aspnetpager分页控件