How do you query the values of textboxes dynamically created in a Panel container??

Discussion in 'ASP .Net' started by SD, May 4, 2005.

  1. SD

    SD Guest

    Hello,

    I have a form that has a panel container where I'm adding textboxes
    dynamically based on a query to database, so I'm looping through the
    records.

    The problem I have is that once built, I need to pass those textboxes values
    to another for to build the parameters for a report.

    Here is the sample:

    While myReader.Read()
    Dim txtBox As New TextBox
    Dim lbLabel As New Label
    parCounter = parCounter + 1

    ' Create dynamic controls here.
    lbLabel.ID = "Label" + parCounter.ToString()
    lbLabel.Text = myReader("parameter") & " "
    lbLabel.Font.Bold = True
    lbLabel.Font.Size = FontUnit.Parse(15)

    lbLabel.ForeColor = Color.Navy
    Page.Controls.Add(lbLabel)
    txtBox.ID = "Textbox" + parCounter.ToString()
    Page.Controls.Add(txtBox)
    Page.Controls.Add(New LiteralControl("<br>"))
    End While

    Dim objButton As New Button
    objButton.Text = " Run Report "
    objButton.ID = "ButtonID"
    'AddHandler objButton.Click, AddressOf ButtonID_Click
    Panel1.Controls.Add(New LiteralControl("<br>"))
    Panel1.Controls.Add(objButton)

    So now on the postback I need to parse through all these values, but can't
    find a single routine to handle this.

    Any ideas???

    SD
    SD, May 4, 2005
    #1
    1. Advertising

  2. Well, if you just need to get the values from the text box, you could do it
    old Request.Forms style.

    string s = null;
    for( int parCounter = 0 ; parCounter == parCounter ; parCounter++ )
    {
    s = Request.Form["TextBox" + parCounter.ToString()];
    if ( s == null ) break; //leaves for loop

    //this is a value from the text box.
    Response.Write( s );
    }

    HTH,

    bill
    "SD" <> wrote in message
    news:1115297659.b4aef7576e0c3f7bbf7d1eb29005b9ce@teranews...
    > Hello,
    >
    > I have a form that has a panel container where I'm adding textboxes
    > dynamically based on a query to database, so I'm looping through the
    > records.
    >
    > The problem I have is that once built, I need to pass those textboxes

    values
    > to another for to build the parameters for a report.
    >
    > Here is the sample:
    >
    > While myReader.Read()
    > Dim txtBox As New TextBox
    > Dim lbLabel As New Label
    > parCounter = parCounter + 1
    >
    > ' Create dynamic controls here.
    > lbLabel.ID = "Label" + parCounter.ToString()
    > lbLabel.Text = myReader("parameter") & " "
    > lbLabel.Font.Bold = True
    > lbLabel.Font.Size = FontUnit.Parse(15)
    >
    > lbLabel.ForeColor = Color.Navy
    > Page.Controls.Add(lbLabel)
    > txtBox.ID = "Textbox" + parCounter.ToString()
    > Page.Controls.Add(txtBox)
    > Page.Controls.Add(New LiteralControl("<br>"))
    > End While
    >
    > Dim objButton As New Button
    > objButton.Text = " Run Report "
    > objButton.ID = "ButtonID"
    > 'AddHandler objButton.Click, AddressOf ButtonID_Click
    > Panel1.Controls.Add(New LiteralControl("<br>"))
    > Panel1.Controls.Add(objButton)
    >
    > So now on the postback I need to parse through all these values, but can't
    > find a single routine to handle this.
    >
    > Any ideas???
    >
    > SD
    >
    >
    William F. Robertson, Jr., May 5, 2005
    #2
    1. Advertising

  3. Re: How do you query the values of textboxes dynamically created i

    Thanks! Your solution solved my problem and it's the easiest one to follow. I
    had been searching for a fix for two days.
    =?Utf-8?B?bGVhcm5pbmdORVQ=?=, Jun 9, 2005
    #3
  4. Re: How do you query the values of textboxes dynamically created i

    Thankyou also, as your answer solved my problem as well.
    I have been trying to figure this out and although I have received help from
    others nothing has seemed to work.

    "William F. Robertson, Jr." wrote:

    > Well, if you just need to get the values from the text box, you could do it
    > old Request.Forms style.
    >
    > string s = null;
    > for( int parCounter = 0 ; parCounter == parCounter ; parCounter++ )
    > {
    > s = Request.Form["TextBox" + parCounter.ToString()];
    > if ( s == null ) break; //leaves for loop
    >
    > //this is a value from the text box.
    > Response.Write( s );
    > }
    >
    > HTH,
    >
    > bill
    > "SD" <> wrote in message
    > news:1115297659.b4aef7576e0c3f7bbf7d1eb29005b9ce@teranews...
    > > Hello,
    > >
    > > I have a form that has a panel container where I'm adding textboxes
    > > dynamically based on a query to database, so I'm looping through the
    > > records.
    > >
    > > The problem I have is that once built, I need to pass those textboxes

    > values
    > > to another for to build the parameters for a report.
    > >
    > > Here is the sample:
    > >
    > > While myReader.Read()
    > > Dim txtBox As New TextBox
    > > Dim lbLabel As New Label
    > > parCounter = parCounter + 1
    > >
    > > ' Create dynamic controls here.
    > > lbLabel.ID = "Label" + parCounter.ToString()
    > > lbLabel.Text = myReader("parameter") & " "
    > > lbLabel.Font.Bold = True
    > > lbLabel.Font.Size = FontUnit.Parse(15)
    > >
    > > lbLabel.ForeColor = Color.Navy
    > > Page.Controls.Add(lbLabel)
    > > txtBox.ID = "Textbox" + parCounter.ToString()
    > > Page.Controls.Add(txtBox)
    > > Page.Controls.Add(New LiteralControl("<br>"))
    > > End While
    > >
    > > Dim objButton As New Button
    > > objButton.Text = " Run Report "
    > > objButton.ID = "ButtonID"
    > > 'AddHandler objButton.Click, AddressOf ButtonID_Click
    > > Panel1.Controls.Add(New LiteralControl("<br>"))
    > > Panel1.Controls.Add(objButton)
    > >
    > > So now on the postback I need to parse through all these values, but can't
    > > find a single routine to handle this.
    > >
    > > Any ideas???
    > >
    > > SD
    > >
    > >

    >
    >
    >
    =?Utf-8?B?S2V6emE=?=, Jun 23, 2005
    #4
    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. Forconi Boris via .NET 247

    TextBoxes created dynamically : How to store data?

    Forconi Boris via .NET 247, Jun 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    372
    Trevor Benedict R
    Jun 18, 2004
  2. RC
    Replies:
    1
    Views:
    575
    Teemu Keiski
    Jun 7, 2005
  3. Nathan Sokalski

    Problem using dynamically created textboxes

    Nathan Sokalski, Jun 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    379
    Nathan Sokalski
    Jun 17, 2005
  4. msimmons
    Replies:
    0
    Views:
    453
    msimmons
    Jul 16, 2009
  5. YunusEmre

    saving text values of dynamically created textboxes

    YunusEmre, Dec 28, 2004, in forum: ASP .Net Building Controls
    Replies:
    15
    Views:
    241
    YunusEmre
    Jan 3, 2005
Loading...

Share This Page