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.
 

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

Top