I've build a simple ASP.NET MVC application with the AdventureWorks database.
I use a ListView control to list the customers (220 rows) and use the DataPager control to enable the paging. In my controller I use the Skip(int) and Take(int) method of Linq to query the current "page".
My questions :
- The datapager control have the QueryStringField to send the page index to the controller but not the size of the collection to be send back (used to set the argument of the skip(int) method)
- I can't use either the
Container.TotalRowCount property to display information about the table ?
Yes I'm aware that the PostBack doesn't exist anymore with a MVC, I mainly developp with Java MVC frameworks like Struts or JSF and I wanted to see how MVC fits in the ASP.NET world.
Your control uses the IQueryable<T> interface, it will not do a paging in memory but with a round trip to the database, is it ?
PagedList<T> will do a roundtrip to the database if your underlying IQueryable<T> is a LINQ to SQL object (i.e. derives from something in System.Data.Linq assembly like Table<TEntity>).
Otherwise it'll use LINQ to Objects (in memory) or whatever your IQueryProvider chooses to use.
Marked as answer by matthieugd on Dec 16, 2007 01:36 PM
Hi Rob,
any chance you could post your complete code for the GetPagingList(..) method you have in an image, in that link above? It's cut off :( I also don't know where it can be found, if it's found in some open source project on codeplex to reference it (read:
i tried to find it first, before I posted here).
thanks rob ... hope you get this :)
:: Never underestimate the predictability of stupidity ::
dude - that post is great!!! i'm already using the PagedList<T> class (i wish that was added to the next Linq framework refresh). I'll definitely impliment this pagenation tommorrow morning when i get into work.
well done!
:: Never underestimate the predictability of stupidity ::
>>>I wrote a very simple "Pagination View User Control" based on the PagedList Code of Rob:
very simple? Yea, if you've played with MVC for 100 hours just on Views sure. I never even knew about
Html.RenderUserControl yet.
Not that I don't value your contribution, I do! It saved my ass. But simple it is not, if you are starting from scratch on this stuff and trying to utilize what Scott Gu wrote for that page class. I did not know how to actually implement it
in the view and now I know because of your post. Otherwise, "simple" is not the case as this stuff is very new yet.
I guess what annoys me is when developers say everything is or was simple and it is or was NOT. There's no reason that you can't say it was hard and I know it is not easy to figure all this out that you posted in one day. The reason people
blog and post is mainly on the stuff usually that is not obvious or is not easy from the start.
I wrote a free asp.net mvc paging component called MvcPager,it has more features and support Ajax paging using MicrosoftAjax or jQuery script library,you can view online demo and download it from
http://en.webdiyer.com/mvcpager
Thank you very much for this great control! This was exactly what I was looking for. I have seen your demos on your page. Is there any additional documentation available such as the *.xml file for intellisense support?
matthieugd
Member
18 Points
9 Posts
ListView and paging with ASP.NET MVC
Dec 13, 2007 08:55 PM|LINK
I've build a simple ASP.NET MVC application with the AdventureWorks database.
I use a ListView control to list the customers (220 rows) and use the DataPager control to enable the paging. In my controller I use the Skip(int) and Take(int) method of Linq to query the current "page".
My questions :
- The datapager control have the QueryStringField to send the page index to the controller but not the size of the collection to be send back (used to set the argument of the skip(int) method)
- I can't use either the Container.TotalRowCount property to display information about the table ?
Matthieu
http://www.virtew.com
robconery
Participant
852 Points
195 Posts
Re: ListView and paging with ASP.NET MVC
Dec 13, 2007 09:06 PM|LINK
Keep in mind that there is no more PostBack, so you can't rely on these controls working properly since they won't know their "state".
ScottGu wrote a nice paging function that I put on my blog here:
http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/
I also wrote up some paging stuff on my blog here (it's toward the end):
http://blog.wekeroad.com/2007/12/06/aspnet-mvc-using-restful-architecture/
Let me know if this helps...
matthieugd
Member
18 Points
9 Posts
Re: ListView and paging with ASP.NET MVC
Dec 14, 2007 06:20 AM|LINK
Thanks,
Yes I'm aware that the PostBack doesn't exist anymore with a MVC, I mainly developp with Java MVC frameworks like Struts or JSF and I wanted to see how MVC fits in the ASP.NET world.
Your control uses the IQueryable<T> interface, it will not do a paging in memory but with a round trip to the database, is it ?
Matthieu
http://www.virtew.com
CVertex
Member
147 Points
128 Posts
Re: ListView and paging with ASP.NET MVC
Dec 14, 2007 11:56 AM|LINK
PagedList<T> will do a roundtrip to the database if your underlying IQueryable<T> is a LINQ to SQL object (i.e. derives from something in System.Data.Linq assembly like Table<TEntity>).
Otherwise it'll use LINQ to Objects (in memory) or whatever your IQueryProvider chooses to use.
pure.krome
Member
532 Points
349 Posts
Re: ListView and paging with ASP.NET MVC
Apr 17, 2008 07:40 AM|LINK
Hi Rob,
any chance you could post your complete code for the GetPagingList(..) method you have in an image, in that link above? It's cut off :( I also don't know where it can be found, if it's found in some open source project on codeplex to reference it (read: i tried to find it first, before I posted here).
thanks rob ... hope you get this :)
[C.I.] Reman
Member
158 Points
44 Posts
Re: ListView and paging with ASP.NET MVC
Apr 17, 2008 08:02 AM|LINK
I wrote a very simple "Pagination View User Control" based on the PagedList Code of Rob:
http://code-inside.de/blog-in/2008/04/08/aspnet-mvc-pagination-view-user-control/
English Blog: Code-Inside International
pure.krome
Member
532 Points
349 Posts
Re: ListView and paging with ASP.NET MVC
Apr 17, 2008 10:41 AM|LINK
dude - that post is great!!! i'm already using the PagedList<T> class (i wish that was added to the next Linq framework refresh). I'll definitely impliment this pagenation tommorrow morning when i get into work.
well done!
dba123
Contributor
2726 Points
1364 Posts
Re: ListView and paging with ASP.NET MVC
Jun 01, 2008 07:28 AM|LINK
>>>I wrote a very simple "Pagination View User Control" based on the PagedList Code of Rob:
very simple? Yea, if you've played with MVC for 100 hours just on Views sure. I never even knew about Html.RenderUserControl yet.
Not that I don't value your contribution, I do! It saved my ass. But simple it is not, if you are starting from scratch on this stuff and trying to utilize what Scott Gu wrote for that page class. I did not know how to actually implement it in the view and now I know because of your post. Otherwise, "simple" is not the case as this stuff is very new yet.
I guess what annoys me is when developers say everything is or was simple and it is or was NOT. There's no reason that you can't say it was hard and I know it is not easy to figure all this out that you posted in one day. The reason people blog and post is mainly on the stuff usually that is not obvious or is not easy from the start.
TaoYang
Member
42 Points
20 Posts
Re: ListView and paging with ASP.NET MVC
Feb 24, 2010 05:58 AM|LINK
I wrote a free asp.net mvc paging component called MvcPager,it has more features and support Ajax paging using MicrosoftAjax or jQuery script library,you can view online demo and download it from http://en.webdiyer.com/mvcpager
MvcPager
ToniStucki
Member
2 Points
1 Post
Re: ListView and paging with ASP.NET MVC
Apr 08, 2010 11:08 AM|LINK
Dear taoyang,
Thank you very much for this great control! This was exactly what I was looking for. I have seen your demos on your page. Is there any additional documentation available such as the *.xml file for intellisense support?