Manually creating HTML... ASP.NET

U

ukbrainstorms

Hi everyone, I have what is usually a familar problem but unsure about
how to solve it in ASP.NET.

I have an array of objects containing information, I would like to
create a table of these objects in my HTML page.

So in PHP, typically I would iterate through the objects generating the
html and storing it in a variable, finally i would output the variable
to the screen, wallah I have a dynamic table of data.

What is the process todo this in ASP.NET, it is difficult to convey
certain procedural steps in a fully OO environment.

Thanks for any help/advice.

Kind Regards
Taz
 
S

S. Justin Gengo [MCP]

Taz,

Put a literal control on your page where you want the table to appear.

Use a stringbuilder object to create your html table.

Then output the stringbuilder (Stringbuilder.ToString) as the text of the
literal.

Of course there are other ways to do this, but that's how to mimic what you
describe exactly.

An easier way however may be to hookup your objects directly to a GridView.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
T

Tarun Mistry

Of course there are other ways to do this, but that's how to mimic what
you describe exactly.

An easier way however may be to hookup your objects directly to a
GridView.

Hi many thanks for your reply!

I have discovered I can use something called a HttpTable control which i
will investigate. Your suggestion will definately come in useful!

However hooking up my objects to a GridView sounds interesting, i wasnt
aware this was possible, please could u provide a little more information?

With kind regards,
Taz
 
S

S. Justin Gengo [MCP]

Taz,

The new asp.net 2.0 GridView object can take a list of objects (use generics
to create the list) as it's datasource. This is done via a new
"ObjectDataSource" control.

There's a great article in the January 2006 Visual Studio Magazine on doing
so. It uses the new generics objects and is really slick. Pick up a copy if
you can.

And microsoft has another how-to here, but I don't think it's using generics
(I only took a brief glance though):

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.aspx



--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top