PC Review


Reply
Thread Tools Rate Thread

Bind a querystring being passed over

 
 
Phillip Vong
Guest
Posts: n/a
 
      28th Aug 2006
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


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      28th Aug 2006
"Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
news:%(E-Mail Removed)...

> 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.


 
Reply With Quote
 
Phillip Vong
Guest
Posts: n/a
 
      28th Aug 2006
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.



"Mark Rae" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
> news:%(E-Mail Removed)...
>
>> 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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
QueryString Value Not Passed through HyperLinkField.DataNavigateUrlFormatString HillBilly Microsoft ADO .NET 0 5th Aug 2009 05:12 AM
Catching directory transversals passed through QueryString Merennulli Microsoft ASP .NET 2 9th Mar 2006 03:06 PM
How to pre-set combo textbox's selectedindex value from querystring passed from another page? ABC Microsoft ASP .NET 2 4th Oct 2005 02:19 PM
HOWTO: Get Querystring Passed To Referring Page Dan Sikorsky Microsoft ASP .NET 3 21st May 2005 01:36 AM
Re: Bind support win2k - Questions about 2000 & Bind Kenneth Porter Microsoft Windows 2000 DNS 9 13th Jul 2003 06:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 AM.