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
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