Hi @ANB ,
The problem now is, for source2 and source3, the datapager doesnt move further than page2. Why this happen ?
According to your description, what you mean is that when you switch the datasource of the ListView control, DataPaper cannot implement the paging function, all data are displayed on one page, right? If this is the case, I have reproduced the issue with the partial code you provided. It is caused by the postback of the page, you can fix this by resetting the pagination parameters after binding the datasource.
Something like this:
protected void MyDropdownSource_Changed(object sender, EventArgs e)
{
var ddlSource = MyDropdownSource.SelectedItem.Value;
switch (ddlSource)
{
case "1":
DataPager1.SetPageProperties(0, 15, true); //send to the first page datapager
ViewState["Listview1Source"] = "source1";
this.BindListView("source1");
DataPager1.PageSize = 4;
break;
case "2":
DataPager1.SetPageProperties(0, 15, false); //send to the first page datapager
ViewState["Listview1Source"] = "source2";
this.BindListView("source2");
DataPager1.PageSize = 4;
break;
case "3":
DataPager1.SetPageProperties(0, 15, false); //send to the first page datapager
ViewState["Listview1Source"] = "source3";
this.BindListView("source3");
DataPager1.PageSize = 4;
break;
}
}
Result:
As you can see, I set PageSize
to 4, you can modify accordingly according to your own situation. But if I misunderstood anything, just let me know.
Best regards,
Xudong Peng
If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.