Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamically created tables

Status
Not open for further replies.

kaijanm

Programmer
May 14, 2003
102
US
I'm pulling a lot of information from a database that I want to show on my page. I currently have it set up so that I create a table and then have a while (datareader.read) that fills in the table which works, but the table is REALLY wide.

Instead, I would like to create a table for each record from the database and then just show the series of tables going down the page.

I added the code to do this, and it compiled and it didn't give any errors at runtime or anything, but when I run it, nothing shows up.

I'm wondering if it has to do with the following: on the version that works, I dragged a table onto the aspx page and then I'm filling that. In the version that doesn't work, I'm doing a tblDep = New Table. Is it that the data is there, it just doesn't show up? Any help would be appreciated.

Thanks!
Kaija
 
Sorry for a moment I thought you were trying to do something crazy like make a new table in the db for each record which you read from the db, but then I realised you meant web page tables.

Creating tables dynamically should work fine. Post the code which does it and I'll see if I can spot where something has gone wrong.



Mark [openup]
 
I probably won't get a chance until Monday, though ;-)


Mark [openup]
 
MONDAY???!!! What??? :) Just Kidding!

Here are pieces...

While rdrDependents.Read()

Dim tblDep As New Table()

Dim r As TableRow = New TableRow()

Dim cSSN As TableCell = New TableCell()
cSSN.Controls.Add(New LiteralControl(rdrDependents.Item("dep_ssn").ToString))

r.Cells.Add(cSSN)

last 3 lines duplicated for other data... then...

tblDep.Rows.Add(r)

End While

I really think that it's probably generating the code, but not displaying it... or, I'm completely off!

Thanks for any help you can give... even if it's not until Monday! :)
 
Well, I'm still here, so you're lucky

Just before the end while,

Me.Controls.Add(tblDep)

This works fine for me

Mark [openup]
 
Thank you! I wouldn't have thought of that!

Can I ask a related question? The tables show up all on the very top left. How do I get them to show up further down on the page? I seem to struggle with gridlayout/flowlayout problems. (maybe I'll post a question about that...)

When I've needed to do this in the past, I put in a div tag and then wrote it to generate raw html to get around this problem.

Now that I think about it, my question isn't so related. (maybe I should be posting lots o' questions)

Thanks! :)
 
I used flow layout when I tried it. I tend to stay away from grid layout - it works for certain things but not for most


Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top