Bind a querystring being passed over

P

Phillip Vong

Please help. I'm a newbie. Using VS2005.

I have a simple aspx page. I want the querystring being passed in to bind
to a textbox in a control. How do you do this?

Basically, www.website.com?string=100

The site autoloads into Formview1 / InsertItem Template. TextBox1 shows up
as blank waiting for me to put in the value "100", but I want Textbox1 to
autograb that value and put it in. Is this possible?

This is what I tried and I really thought this would work:
In page load:
Dim Answer as string
Answer = Request.Querystring("string")
Formview1.InsertItemTemplate.Textbox1 = Answer


Thanks!

Phil
 
M

Mark Rae

Please help. I'm a newbie. Using VS2005.

I have a simple aspx page. I want the querystring being passed in to bind
to a textbox in a control. How do you do this?

Basically, www.website.com?string=100

The site autoloads into Formview1 / InsertItem Template. TextBox1 shows
up as blank waiting for me to put in the value "100", but I want Textbox1
to autograb that value and put it in. Is this possible?

This is what I tried and I really thought this would work:
In page load:
Dim Answer as string
Answer = Request.Querystring("string")
Answer = Request.Querystring("string").ToString()
Formview1.InsertItemTemplate.Textbox1 = Answer
Formview1.InsertItemTemplate.Textbox1.Text = Answer

Several points:

1) Try to get out of the habit of accepting the default control names e.g.
Formview1, Textbox1 etc and try to use more descriptive names instead.

2) The code above does not have any error handling e.g. what happens if the
Querystring doesn't contain a "string" name/value pair?

3) Try to avoid using reserved words (e.g. "string") for variables.
 
P

Phillip Vong

Thanks Mark!

Someone at another site told me to just put request.querystring("answer") in
the custom binding of that textbox and this worked perfectly.
 
Joined
May 2, 2008
Messages
2
Reaction score
0
Mark Rae said:
"Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
news:%[email protected]...

> Please help. I'm a newbie. Using VS2005.
>
> I have a simple aspx page. I want the querystring being passed in to bind
> to a textbox in a control. How do you do this?
>
> Basically, www.website.com?string=100
>
> The site autoloads into Formview1 / InsertItem Template. TextBox1 shows
> up as blank waiting for me to put in the value "100", but I want Textbox1
> to autograb that value and put it in. Is this possible?
>
> This is what I tried and I really thought this would work:
> In page load:
> Dim Answer as string
> Answer = Request.Querystring("string")

Answer = Request.Querystring("string").ToString()

> Formview1.InsertItemTemplate.Textbox1 = Answer

Formview1.InsertItemTemplate.Textbox1.Text = Answer

Several points:

1) Try to get out of the habit of accepting the default control names e.g.
Formview1, Textbox1 etc and try to use more descriptive names instead.

2) The code above does not have any error handling e.g. what happens if the
Querystring doesn't contain a "string" name/value pair?

3) Try to avoid using reserved words (e.g. "string") for variables.
Mark,

I have the same issue that Philip was having and tried your suggestion but I still keep getting an error...

Here is my code

Dim RE As String
Dim RCID As String

RE = Request.QueryString("RespEmail").ToString()
RCID = Request.QueryString("RespCustID").ToString()

FormView1.InsertItemTemplate.RespEmail.Text = RE
FormView1.InsertItemTemplate.RespCustID.Text = RCID

Both bottom lines are underlined up to the .Text part and I get two errors that say "RespEmail is not a member of System.Web.UI.ITemplate"

Help!!! What am I doing wrong?

John.
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top