Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do you query the values of textboxes dynamically created in a Panel container??

Reply
Thread Tools

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

 
 
SD
Guest
Posts: n/a
 
      05-04-2005
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


 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      05-05-2005
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" <(E-Mail Removed)> wrote in message
news:1115297659.b4aef7576e0c3f7bbf7d1eb29005b9ce@t eranews...
> 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
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?bGVhcm5pbmdORVQ=?=
Guest
Posts: n/a
 
      06-09-2005
Thanks! Your solution solved my problem and it's the easiest one to follow. I
had been searching for a fix for two days.
 
Reply With Quote
 
=?Utf-8?B?S2V6emE=?=
Guest
Posts: n/a
 
      06-23-2005
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" <(E-Mail Removed)> wrote in message
> news:1115297659.b4aef7576e0c3f7bbf7d1eb29005b9ce@t eranews...
> > 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
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
Get Value From Dynamically Created TextBoxes...... RC ASP .Net 1 06-07-2005 05:44 AM
saving text values of dynamically created textboxes YunusEmre ASP .Net Building Controls 15 01-03-2005 03:06 PM
TextBoxes created dynamically : How to store data? Forconi Boris via .NET 247 ASP .Net 2 06-18-2004 09:09 AM



Advertisments