472,954 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

Passing in a variable using a query string

I haven't done any web work for over a year and for the life of me I cannot
remember how to use a query string in a URL. I want the link to be
page.aspx?ID=1 then pass 1 into a query like this

select * from table where id = "query string value"

I know it's simple, I just haven't done it for a long time. Can somebody
please help me out? Thanks
Jul 21 '05 #1
2 1956
The System.Web.HttpContext.Current.Request.QueryString property will
return a NameValueCollection containing all of the variables in the
query string.

So in csharp, this:
System.Web.HttpContext.Current.Request.QueryString["ID"]

....will return the value of ID variable in the query string.

Jul 21 '05 #2
Hi Andy,

Its very simple...

If you want to pass data (value) from pageA to pageB on click of a button,
then on the click event of the button in pageA..

Response.Redirect("FULL_URL_OF_THE_PAGE?Value1=" + Value_you_want_to_send +
"&Value2=" + Value_you_want_to_send);

And in pageB page load event (in the if(!postback)) capture the query string
value like this...

string query = "select * from Products where ProductID='" +
Request.QueryString [ "Value1" ] + "'";

As Bryan explained, A NameValueCollection containing the collection of query
string variables will be sent to the next page.

NOTE: In this example i have given how to capture for 2 values in Query
string.

Need any help, do post a msg back..
Happy Coding.

"Andy" wrote:
I haven't done any web work for over a year and for the life of me I cannot
remember how to use a query string in a URL. I want the link to be
page.aspx?ID=1 then pass 1 into a query like this

select * from table where id = "query string value"

I know it's simple, I just haven't done it for a long time. Can somebody
please help me out? Thanks

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
7
by: rickcheney | last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I had a form where the user entered a value into a text box and when a command button on the form was clicked a Report was...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
1
by: Deecrypt | last post by:
Hi, Passing a string parameter to a webservice to get the dataset generated as the result, seems to give me an error suggesting that no parameter is being passed. However it works if I explicitly...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
11
by: Purdue02 | last post by:
I am trying to pass a global variable to criteria in a query using the below code, but the query is returning no results. I have the function ReturnStrCriteria() included in the query's criteria....
1
globalguideline
by: globalguideline | last post by:
Hi all here at forum. I am working to find out some solution to access a web page in PHP that is showing information on the bases of given argument in query string variable. My problem is this that...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.