ASP Table

  • Thread starter Thread starter ^MisterJingo^
  • Start date Start date
M

^MisterJingo^

Hi all,

I'm dynamically creating a table based upon user feedback, and I need
to databind some of the items.
I've not had much success looking for examples on this through google,
but I've found I can access controls placed into the table as such:

((DropDownList)tblLayout.Rows[0].Cells[1].Controls[0]).DataSource =
_ds.Tables["hours"];

This works. But it seems to me to be a lot of code and it is very
obscure. Is there a simpler way to access controls in a dynamic table?
The other option I have is to mix html and code together <% %> and
only show parts of the table needed. But once again, I would rather not
mix code and html if I can avoid it (although it would be much clearer
than the first example).

Any help would be appreciated.
 
^MisterJingo^ said:
Hi all,

I'm dynamically creating a table based upon user feedback, and I need
to databind some of the items.
I've not had much success looking for examples on this through google,
but I've found I can access controls placed into the table as such:

((DropDownList)tblLayout.Rows[0].Cells[1].Controls[0]).DataSource =
_ds.Tables["hours"];

This works. But it seems to me to be a lot of code and it is very
obscure. Is there a simpler way to access controls in a dynamic table?
The other option I have is to mix html and code together <% %> and
only show parts of the table needed. But once again, I would rather not
mix code and html if I can avoid it (although it would be much clearer
than the first example).

Any help would be appreciated.

I found the following command which seems to help:

table.FindControl(<control name>);

I'm worried that dynamically creating a table, and then databinding to
controls it contains using a method which searches through the table
object each time is going to incur quite a performance hit.
An alternative is to use a standard html table and then use code in
the html to remove entire rows based on conditions. It's messier but
seems like it would be a lot more efficient.
I'd be interested to hear how others solve such problems as this. Am I
worrying unnecessarily about performance hits?

Thanks.
 

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

Back
Top