London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Using SearchDataSource with the ASP.NET DataPager and ListView Controls

Vote:
 

Hi,

Can anyone confirm if the SearchDataSource control supports paging functionality with the ASP.NET DataPager and ListView controls?

I'm trying to get them to work together with no joy. Basically, when I click on say, page 2 of the pager, the same results are shown on page 2 as were shown on page 1. The DataPager certainly restricts the page size, e.g. if I tell it to return 10 items per page this does seem to work.

I have run into this problem before when not using SearchDataSource and it was solved by re-binding the ListView on the PagePropertiesChanged event. This does not seem to work in this case.

Any ideas or comments?

Thanks a lot,

Robert

#45823
Nov 18, 2010 18:08
Vote:
 

The solution here seems to be to use the select method of the SearchDataSource in the code behind of your page:

1. In the OnPreRender event of your page do your initial databinding e.g.:

myListView.DataSource = mySearchDataSource.Select(DataSourceSelectArguments.Empty);
myListView.DataBind();

2. Add an event handler for your ListView's PagePropertiesChanged event to rebind the ListView e.g.:

private void myListView_PagePropertiesChanged(object sender, EventArgs e)
{
     myListView.DataSource = mySearchDataSource.Select(DataSourceSelectArguments.Empty);
     myListView.DataBind();
}

Bingo, your DataPager should now work correctly.

Robert

#45848
Nov 19, 2010 13:50
Vote:
 

Confirmed. Without this I was unable to get DataPager to work with SearchDataSource (it shows first page no mater what i put in the querystring)

#50323
Edited, Apr 27, 2011 13:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.