question about proper way to show an IList of objects?

F

Flip

I have created an object and added a bunch of them to an IList. What is the
suggested way to display them using ASPX? I'm currently doing it the old
ASP (or worse, the JSP) way of coding up an html table and scriptlet tags
iterating through the IList calling the getters.

But that seems a bit cumbersome and some how my gutt tells me that's not the
best .NET solution. Can anyone suggest a better way?

I've looked at the Repeater control, but all the examples I've read show me
how to do this with a database, but I'm creating the objects in the IList.

Thanks.
 
B

Brock Allen

You should look into DataBinding -- the Repeater would work just fine. As
would the DataGrid. This should get you started:

<asp:DataGrid runat=server id=_grid />

void Page_Load()
{
_grid.DataSource = YourList;
_grid.DataBind();
}

As long as your objects in the list has public properties, then the Grid
will auto-gen columns from all those properties. You would probabaly want
to then customize this with templates, so all the samples you've seen that
use databases should work very similarly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top