Connecting Tech Pros Worldwide Forums | Help | Site Map

Accessing textbox control in a table cell

Bass Pro
Guest
 
Posts: n/a
#1: Nov 19 '05
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.
--
Bill Jones

vMike
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Accessing textbox control in a table cell



"Bass Pro" <BassPro@discussions.microsoft.com> wrote in message
news:5B77B793-EAD4-4A80-8EEB-C340D8E85F35@microsoft.com...[color=blue]
> 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 =[/color]
CType(tl.Rows(0).Cells(0).FindControl("Answer_1"),[color=blue]
> TextBox)
> and it doesn't. tb is always "Nothing".
>
> Where am I wrong?
> TIA.
> --
> Bill Jones[/color]

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



Bass Pro
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Accessing textbox control in a table cell


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,
--
Bill Jones


"vMike" wrote:
[color=blue]
>
> "Bass Pro" <BassPro@discussions.microsoft.com> wrote in message
> news:5B77B793-EAD4-4A80-8EEB-C340D8E85F35@microsoft.com...[color=green]
> > 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 =[/color]
> CType(tl.Rows(0).Cells(0).FindControl("Answer_1"),[color=green]
> > TextBox)
> > and it doesn't. tb is always "Nothing".
> >
> > Where am I wrong?
> > TIA.
> > --
> > Bill Jones[/color]
>
> I don't see were you are giving the textbox an id as in
> Answer_1.ID="Answer_1"
>
>
>
>[/color]
Closed Thread