Designing Table Programmatically

G

Guest

I need to create some tables on a web page at run time rather than design
time. There could be 1 - 5 tables on the page depending on options. I've
created the tables by creating the cells, rows, and tables just as I want
them, but I don't know how to get them to render. Is there a function to add
the html code for the tables to the aspx file during run time? What is the
best way to handle this. Any examples I find to creating tables
programmatically has the programmer manually add the html code to the aspx
file during design time rather than creating them dynamically for a different
number of controls.
 
K

Kevin Spencer

You just create HtmlTable Controls and add them to the Controls Collection
of the WebForm.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
P

Peter Rilling

You add them to the Controls property for some parent element. When you say
that you created the cells and rows, do you mean actual TableCell and
TableRow objects?

1) Add some container to your HTML like a DIV. Something that you can
reference in code.
2) Mark this as "runat=server".
3) Add the Table object to the Controls property for the DIV. The table
should then render.
 
G

Guest

Use HTMLtextwriter to render and write this in the render event.
Or
Drop placeholder object in the aspx page ...and add controls to it whatever
u have created dynamically
Or
Add controls to Form itself but here u can place it exactly in the way u
need it.
 
C

Charlie@NISH

You can send HTML markup to browser using
Response.Write("HTMLstringthatbuildstables")

Charlie
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top