I have a Gridview, which is bound to an IList. I’d like to have paging ‘ the safer way’ (only fetching the Items I Need), so I created a metod on my repository like this
public Ilist<Item> GetItems(int from, int number){ ... }
The thing is that wheen I bind it, it only shows me the n items, and doesn’t show the paging controls. I tried to find the way to tell the gridview how many elements I have on my resultset with
public int CountItems{ get{ ... } }
but I didnt find a place to tell the GV this value.
What is the strategy here? Is it necessary to have an ObjectDS? I refuse to belive so!
What can I do to have Paging?
Unfortunately you do need an Object DataSource or implementing a custom datasource. Here is a link to the msdn doc that mentions it http://msdn.microsoft.com/en-us/library/5aw1xfh3.aspx. Datagrid did supported doing what you want, but ms didn’t do the same for GridView.
I guess an option would be to create some kind of dummy custom datasource, that would expose the methods/events that you need to still control the process outside of it.