ASP.NET Textbox.Text Property not updating

Joined
Oct 2, 2009
Messages
1
Reaction score
0
Hi all,

I have been looking throughout the forum however I haven't managed to find a solution to the problem I am encountering.

I have dynamically created a number of textboxes stored in an array using Code Behind. When the user presses a button I want to be able to read the value in those textboxes, however I am reading the old value ("") instead.

I have included the relevant code below.



//array of textboxes
public static TextBox[] txtParameters;


//the text boxes are created dynamically based on what the user chooses from a list, ID = lstMethod
protected void lstMethod_SelectedIndexChanged(object sender, EventArgs e)
{

//tblParameters is Table control in the .aspx used to display the text boxes
tblParameters.Rows.Clear();
txtParamaters = new TextBox[Convert.ToInt32(lstMethod.SelectedIndex.Text)];
for (int i; i < Convert.ToInt32(lstMethod.SelectedIndex.Text); i++)
{
TableRow tableRow = new TableRow();

TableCell label = new TableCell();
label.Text = i;
tableRow.Cells.Add(label);

TableCell data = new TableCell();
txtParameters = new TextBox();
data.Controls.Add(txtParameters);

tableRow.Cells.Add(data);
tblParameters.Rows.Add(tableRow);
}
}


//once btnDone is clicked, the values in txtParameters are read
protected void btnDone_Click(object sender, EventArgs e)
{
for(int i = 0; i < txtParameters.Length; i++)
{
txtParameters.Text;
}
}


Thank you, much appreciated
Kevin
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top