Table Rows

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hello,

I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
TableRows object.

Any ideas why I can't then itterate through the table object and reference
each of the rows using:

Dim tb as tablesRow
For Each tr In tbl.Rows
xx = tr.Cells(1).Text
Next

There appears to be no rows in the table ie. tbl.tablerows.count = 0

TIA

Tim
 
Dim t as new table

Page.Controls.Add(t)

Dim r As TableRow

Dim c As TableCell

For i As Int32 = 0 To 5

r = New TableRow

c = New TableCell

c.Text = i.ToString

r.Cells.Add(c)

t.Rows.Add(r)

Next

For Each r In t.Rows

Response.Write("<BR>Cell Value = " & r.Cells(0).Text)

Next
 
Tim,

If you are trying to access the rows on postback, note, that you have to
re-create dynamucally created objects in the code.

Eliyahu
 

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