ASP.NET Textbox.Text Property not updating

Discussion in '.NET' started by SpaceCake, Oct 2, 2009.

  1. SpaceCake

    SpaceCake

    Joined:
    Oct 2, 2009
    Messages:
    1
    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
     
    SpaceCake, Oct 2, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sekisho@gmail.com

    asp.net textbox text not updating

    sekisho@gmail.com, May 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    13,709
    David Lloyd
    May 7, 2005
  2. Alani
    Replies:
    2
    Views:
    2,050
    Alani
    Jan 22, 2006
  3. erikpaulmiller@gmail.com

    WML Input and .NET TextBox not displaying Text Property

    erikpaulmiller@gmail.com, Nov 10, 2005, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    262
    erikpaulmiller@gmail.com
    Nov 10, 2005
  4. ErwinP
    Replies:
    1
    Views:
    759
    ErwinP
    Aug 19, 2005
  5. Jurjen de Groot
    Replies:
    0
    Views:
    314
    Jurjen de Groot
    May 19, 2008
Loading...

Share This Page