findcontrol behaviour

T

tarscher

Hi all,

When a user clicks a button controls are generated
protected void keywordsDropDownList_SelectedIndexChanged(object
sender, EventArgs e)
{
int numberOfTextBoxes =
Convert.ToInt16(keywordsDropDownList.Text);
TextBox myTextBox;

for (int i = 0; i < numberOfTextBoxes; i++)
{
myTextBox = new TextBox();
myTextBox.ID = "parameterTextBox" + Convert.ToString(i);
myTextBox.Columns = 5;
buttonPlaceHolder.Controls.Add(myTextBox);
}
addKeywordButton.Visible = true;
MultiView1.SetActiveView(KeywordView);

TextBox myTB;
myTB =
(TextBox)buttonPlaceHolder.FindControl("parameterTextBox1");
}

The FindControl finds the parameterTextBox1 and copies it to myTB
correctly.

When a user now clicks a button after he clicked the previous one I do:
protected void addKeywordButton_Click(object sender, EventArgs e)
{
TextBox myTB;
myTB =
(TextBox)buttonPlaceHolder.FindControl("parameterTextBox1");
}

Here FindControl can't find the control and myTB is null.

I really can't find the problem so any help is greatly appreciated.

best regards
Stijn
 

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

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top