Click to See Complete Forum and Search --> : Looping through controls in a table


Broodmdh
March 21st, 2006, 01:04 PM
I am adding rows to a table, and controls to the cells within the rows, during runtime. Some of the controls are checkboxes, and I want to determine which ones have been checked. When I try looping through the controls (either the controls on the page, or the controls in the table), it doesn't seem to work. I set the ID for each control, but when I loop through the controls the ID's are always blank. My code is as follows (it gets run at every page load to maintain state):

Dim fRow As TableRow
Dim fCell As TableCell

For Each filePath In tmpList
Dim varCheck As New CheckBox
Dim varTitle As Label = New Label
Dim varSize As Label = New Label
Dim varLink As New HyperLink

....... '(I create and assign ID's to the controls here)

fRow = New TableRow
fCell = New TableCell
fCell.Wrap = True
fCell.Width = Unit.Pixel(25)
fCell.Controls.Add(varCheck)
fRow.Cells.Add(fCell)

fCell = New TableCell
fCell.Wrap = True
fCell.Width = Unit.Pixel(330)
fCell.Controls.Add(varTitle)
fRow.Cells.Add(fCell)

fCell = New TableCell
fCell.Wrap = True
fCell.Width = Unit.Pixel(45)
fCell.Controls.Add(varSize)
fRow.Cells.Add(fCell)

fCell = New TableCell
fCell.Wrap = True
fCell.Width = Unit.Pixel(25)
fCell.Controls.Add(varLink)
fRow.Cells.Add(fCell)

fTable.Rows.Add(fRow)
Next

allomeen
March 22nd, 2006, 01:35 AM
How did you set the ID's?

Broodmdh
March 22nd, 2006, 07:24 AM
I've just been setting the ID's with concatenated strings, like the following:

var1.ID= string1 & string2

When I send the ID to the output using trace.writeline, everything appears normal. If the ID contains a "." (a simple period), would that have any impact (I doubt it, but I thought I should ask).