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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Table Not Appearing

Status
Not open for further replies.

sbushway

Programmer
Jan 27, 2003
58
0
0
US
Hi,
I'm dynamically creating a table in my code-behind but the table never appears when I run the program. Here's what I have so far:

Code:
Dim tbl As New Table
tbl.Width = 700
tbl.CellPadding = 0
tbl.CellSpacing = 0
tbl.Visible = True

Dim trHeaderRow01 As New TableRow

Dim tCell01 As New TableCell
tCell01.Text = "CYCLE"
trHeaderRow01.Cells.Add(tCell01)

Dim tCell02 As New TableCell
tCell02.Text = globalDV.Item(i).Item("rptcycle").ToString
trHeaderRow01.Cells.Add(tCell02)

Dim tCell03 As New TableCell
tCell03.Text = "RATING CHANGE AUTHORIZATION"
trHeaderRow01.Cells.Add(tCell03)

Dim tCell04 As New TableCell
tCell04.Text = globalDV.Item(i).Item("rptdate").ToString
trHeaderRow01.Cells.Add(tCell04)

tbl.Rows.Add(trHeaderRow01)

I've stepped through this section in my program and there is data to be filled into the table, so I doubt that's the problem.

Any idea why my table doesn't appear when I run it?

Thanks in advance,
Suzanne
 
I copied your code into a new project and it is working for me.

Explain to me how you are trying to display this table data?
I am pretty sure the problem lays within that area.
 
I also watch the ASP.Net Forum, so I don't mind helping you at all Suzanne.
 
Hi again,

Well, I just figured it'd be a VB.NET question since I'm creating the table in my code-behind ...

Essentially the situation is this: I've got a bunch of data, grouped by a specific number. For instance, I'll have 1 record under 00001, 2 records under 00002, 1 record under 00003, etc. Every time the number is different, I want to print out a different header, containing that new number.

I read about nested repeaters, but I never quite understood how to implement them. And the query that outputs the data is so full of nested INNER and OUTER JOINs, I wasn't really keen on the idea of trying to re-write it to make it work for nested repeaters.

So since I've worked with dynamic tables before, I didn't think I'd have too much trouble (apparently I was wrong ...)

I'm calling a function from my Page_Load(). This function in turn calls a 'check' function (CheckUIC) to see if the number of the current row is the same as the number of the previous row - if it is, don't print out the header. If it's not the same, print out a new header, containing the new number.

Code:
 If CheckUIC(globalDV.Item(i).Item("uic_ctrl").ToString) = False Then

   Dim tbl As New Table
   tbl.Width = 700
   tbl.CellPadding = 0
   tbl.CellSpacing = 0
   tbl.Visible = True

   Dim trHeaderRow01 As New TableRow

   Dim tCell01 As New TableCell
   tCell01.Text = "CYCLE"
   trHeaderRow01.Cells.Add(tCell01)

   Dim tCell02 As New TableCell
   tCell02.Text = globalDV.Item(i).Item("rptcycle").ToString
   trHeaderRow01.Cells.Add(tCell02)

   Dim tCell03 As New TableCell
   tCell03.Text = "RATING CHANGE AUTHORIZATION"
   trHeaderRow01.Cells.Add(tCell03)

   Dim tCell04 As New TableCell
   tCell04.Text = globalDV.Item(i).Item("rptdate").ToString
   trHeaderRow01.Cells.Add(tCell04)

   tbl.Rows.Add(trHeaderRow01)
End If

So if it's working for you, it must mean that there's something in my logic.

I noticed something funny - if I create a table in the HTML of my .ASPX page, but with no TR or TD tags (just TABLE tags), and add rows and columns to that table in my code-behind, I can get data to show up.

But if I create the table from my code-behind, it's not working.

Weird...

Thanks again for your help!
Suzanne
 
I figured it out - I'm a dummy. I forgot to do the "Me.Controls.Add(tbl)" to my code.

Sorry about that :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top