[RESOLVED] findcontrol = finding textbox in a table row
HI Guys,
When I add a textbox to my table cell then then add the table cell to the table row. Then I try access that control it always comes back null.
Code:
newTextBox = new TextBox();
newTextBox.ID = "row_1Col_1";
newTextBox.Font.Size = FontUnit.Medium;
newTextBox.Width = 70;
newTextBox.Text = "Blah"
acell.Controls.Add(newTextBox);
arow.Cells.Add(acell);
After the last line of code I break and try a quick watch.
acell.FindControl("row_1Col_1") which comes back null
I also try
arow.FindControl("row_1Col_1") which also comes back null.
before this code I do a quick watch on arow.controls.count which comes back as 0, then after the code I do the same thing and it comes back as 1. So I know it's getting added, but can't seem to get back to the textbox value.
is there a way to list all the controls or something? Because I think it changes the name or something.
I know this code is in C#, but it's the same idea in VB. IF I'm wrong please redirect the post to the right thread thanks.
Re: findcontrol = finding textbox in a table row
Actually I just found this. If I do this:
HTML Code:
Control ctrl = arow.Cells[1].Controls[0];
TextBox tc = ctrl as TextBox;
After arow.Cells.Add(acell);
Then I get my textbox. So I'll just do it this way, but still not sure why findcontrol doesn't work. Any ideas?
Re: findcontrol = finding textbox in a table row
Hello,
The only thing that I can think is that the ID wasn't being found. From what I can see, it "should" have worked.
Glad to got it working though, can you remember to mark your thread as Resolved?
Thanks
Gary