Accessing textbox control in a table cell

G

Guest

How do I access a textbox when it was added to a table cell?
I've tried using the findcontrol function with no result.

I create it as such...
Dim myTable As Table = New Table
Dim Row as TableRow

row = New TableRowI
Answer_1 = New TextBox
Answer_1.Width = New Unit("100px")
Answer_1.Text = " "
cell = New TableCell
cell.Controls.Add(Answer_1)
row.Cells.Add(cell)
myTable.Rows.Add(row)
myTable.ID = "myTable5"
I expected this to work:
tl = CType(pnlBoard.FindControl("myTable" &
CStr(QuestionTypeID)), Table)

tb = CType(tl.Rows(0).Cells(0).FindControl("Answer_1"),
TextBox)
and it doesn't. tb is always "Nothing".

Where am I wrong?
TIA.
 
V

vMike

Bass Pro said:
How do I access a textbox when it was added to a table cell?
I've tried using the findcontrol function with no result.

I create it as such...
Dim myTable As Table = New Table
Dim Row as TableRow

row = New TableRowI
Answer_1 = New TextBox
Answer_1.Width = New Unit("100px")
Answer_1.Text = " "
cell = New TableCell
cell.Controls.Add(Answer_1)
row.Cells.Add(cell)
myTable.Rows.Add(row)
myTable.ID = "myTable5"
I expected this to work:
tl = CType(pnlBoard.FindControl("myTable" &
CStr(QuestionTypeID)), Table)

tb = CType(tl.Rows(0).Cells(0).FindControl("Answer_1"),
TextBox)
and it doesn't. tb is always "Nothing".

Where am I wrong?
TIA.

I don't see were you are giving the textbox an id as in
Answer_1.ID="Answer_1"
 
G

Guest

I do it when I dynanmically create the table control.

The table is placed on a panel control dynamically based on parameters to
the type of question template selected by the admin user. I'm trying t
create a "Range" type answer where there is an "Answer_1" and an "Answer_2"
box the end user fills in. The number of possible options are unknown at
design time, so it has to be done dynamically.
Txs,
 

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

Top