views:

188

answers:

2

Does anyone have any recomendation on how to implement pageing in ASP.NET webforms when applying the MVP pattern? I'm wondering where to put the paging logic...in the view or in the presenter? Also a neet way to implement pageing in ASP.NET is to use the PagedDataSource control... would it be correct to use that from a presenter or would we better of implementing some custom pageing logic. The data is displayed in the view using a Repeater control.

Cheers!

+1  A: 

Hi, I don't know exactly, what difference is there between mvp and mvc, so I think this post might be useful to you. I personally like the idea to create a hepler outside model or controller(presenter?). Also jquery paging mechanism is pretty straight forward. In presenter just add parameters for requested rows of data and return only those instead of whole table/grid/whatever.

Trimack
+1  A: 

I think both the View and the Presenter need to know about paging. Here's why:

  • Intelligent paging should only retrieve data needed to fill a page. This is a collaboration between the Presenter and the Model in my mind. In pedantic MVP, the View has no knowledge of the Model, so the Presenter must be the go-between. In MVC, you might get away with excluding the Controller with a strong enough domain model.
  • The View needs to know about paging so that the user can interact properly with the paging metaphore (Next, Prev, proper rendering, etc)

I'm not terribly familiar with the PagedDataSource. If you're using WebForms, you're probably hosed if you want to stick to a faithful implementation of MVP. Perhaps you could set up the page caching for the PagedDataSource (if there is such a thing) in the Presenter and the GUI glamour in the View. It would mean passing around a reference to a user control, but maybe that's okay.

Kudos to you for trying to make MVP work with WebForms. I'd love to hear how it turns out.

Nick Monkman