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
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