i want to ask a question about how to do paging in ASP.net coding with C#.
the thing i try to do is that, i want to display some content, have multi column and multi rows.
in the actually coding, i have a list of object, let say Object A
class A {
integer id;
string name;
string desc;
}
and want to display this onto the page with pagable functionality.
i do google search, ASP.net offer gridview and listview, but they all require a datasource, which mean that table directly bind to the database.
that is not what i want, coz my list of object A come from some where else, not from my database (e.g it is a composite set of data, which generate in runtime)
so it there anyway i still can use those benifit component, or i have to do it all on my own for the paging???
thx
Best Answer
My advice is to use a GridView, with which you can use an ObjectDataSource, which can take its underlying data from a class method that you specify. So the class method might be (following your code example):
and your aspx page would contain
The
TypeName
andSelectMethod
attributes of the ObjectDataSource tell it which method, and where, to use to fill the ODS with data. TheAllowPaging="True"
gives you paging on the GridView automatically.