AspNetPager分页问题
三个控件Repeater、AspNetPager、DropDownListDropDownList控件SelectedIndexChanged事件,在SelectedIndexChanged事件中绑定Repeater、AspNetPager查询相应的值
如果DropDownList的一个选项查询到数据,Repeater显示数据,AspNetPager显示分页。
再去点DropDownList另一个选项,这个选项没有查询到数据,Repeater没有数据,但是AspNetPager显示的分页却是第一个有数据时显示的分页数。
应该怎么解决 --------------------编程问答-------------------- 我是存储过程分页了 参数带StartIndex 和EndIndex
调用时候传AspNetPager1.StartRecordIndex, AspNetPager1.StartRecordIndex+9 就是每次读10条
在SelectedIndexChanged查询时传值
新手 有错见谅~ --------------------编程问答-------------------- 再去点DropDownList另一个选项 时候是否有重新绑定数据呢? --------------------编程问答--------------------
同一个DropDownList,同一个SelectedIndexChanged,选项不同查询的值不同而已 --------------------编程问答-------------------- 那要看你的代码怎么写了 --------------------编程问答-------------------- 把全部代码贴出来吧 --------------------编程问答--------------------
--------------------编程问答--------------------
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitRpt();
}
}
public void InitRpt()
{
DataSet ds = 查询数据,根据DropDownList1.SelectedItem.Value
PagedDataSource pdsList = new PagedDataSource();
pdsList.DataSource = ds.Tables[0].DefaultView;
pdsList.AllowPaging = true;//数据源允许分页
pdsList.PageSize = Repeater1.PageSize;//取控件的分页大小
pdsList.CurrentPageIndex = Repeater1.CurrentPageIndex - 1;//显示当前页
// 设置控件
Repeater1.RecordCount = ds.Tables[0].Rows.Count; //记录总数
this.repList.DataSource = pdsList;
this.repList.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
InitRpt();
}
--------------------编程问答-------------------- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitRpt();
}
}
public void InitRpt()
{
DataSet ds = 查询数据,根据DropDownList1.SelectedItem.Value
PagedDataSource pdsList = new PagedDataSource();
pdsList.DataSource = ds.Tables[0].DefaultView;
pdsList.AllowPaging = true;//数据源允许分页
pdsList.PageSize = Repeater1.PageSize;//取控件的分页大小
pdsList.CurrentPageIndex = Repeater1.CurrentPageIndex - 1;//显示当前页
// 设置控件
Repeater1.RecordCount = ds.Tables[0].Rows.Count; //记录总数
this.repList.DataSource = pdsList;
this.repList.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
InitRpt();
}
{
pdsList.CurrentPageIndex = 1;//显示第一页
InitRpt();
}
这样试试 --------------------编程问答--------------------
PagedDataSource pdsList = new PagedDataSource();
应该是Repeater1.CurrentPageIndex = 1;吧,事了不行啊 --------------------编程问答-------------------- protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitRpt(1);
}
}
public void InitRpt(int PageIndex)
{
pdsList.CurrentPageIndex = PageIndex - 1;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
InitRpt(1);
} --------------------编程问答--------------------
pdsList.CurrentPageIndex =0;
不行啊 --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 同求 --------------------编程问答-------------------- --------------------编程问答--------------------
补充:.NET技术 , ASP.NET