Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a page that pulls some SQL data results using the id from the
url:

PropertyDetails.aspx?id=63

I need to create a hyperlink that uses the id from the url to open a survey that corresponds to that id.

I would like to have it were the hyperlink pulls the id from the url dynamically so I dont have to code all the pages with the id in the link manually.




Any assistance would be GREATLY appreciated.

Thanks Much!

Rajkumar
Posted

Try this in the codebehind where that hyperlink redirects, e.g. PropertyDetails.aspx?id=63

In codebehind PageLoad
C#
Int32 propertyIdFromQueryString = 0;
if( Int32.TryParse( Request.QueryString[ "id" ], out propertyIdFromQueryString ) )
{
   //you can now use propertyIdFromQueryString as the id to query your database 
}
else
{
   //means the query string sent is not a valid interger!
}


All you simply use is the ASP.NET Request.QueryString["QueryStringName"] e.g. id in this case, to find out more here you are:
Passing variables between pages using QueryString[^]

Happy coding,
Morgs
 
Share this answer
 
v2
Comments
rajkumar9867 8-Oct-11 5:17am    
Thanks alot Morgs You are the best I am your fan ....Can i have your email address.....
Espen Harlinn 8-Oct-11 5:17am    
This reply, together with Abhinavs' reference provides a nice solution, my 5
Morgs Morgan 8-Oct-11 11:01am    
Thanks guys :)..
rajkumar9867, it's not very safe to write your e-mail address on a public forum.
If you are using ASP.Net, then you can read about hyperlinks here - Code Project - Frequently Asked Questions Series 1: The ASP.Net GridView[^].
 
Share this answer
 
Comments
Espen Harlinn 8-Oct-11 5:18am    
My 5 :)
Abhinav S 8-Oct-11 5:24am    
Thank you Espen.
 
Share this answer
 
Comments
rajkumar9867 8-Oct-11 6:02am    
Thanks a lot you gave me exactly what i want ...
You are true genius.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900