I wasn't 100% sure where this thread belonged, so I put it in here.
I have a gridview whose data (UserID, UserName etc) is populated from an SQL Database. I have a hyperlink in this gridview so that you can click on a user's username and you get redirected to a separate page with a URL like userManagement.aspx?<userID> that
is going to show information relative to that user (username, contact details etc) so that they can be updated.
At the moment, everything seems to be fine except I don't know how to use or retrieve the userID that is passed through in the URL. For example, I can click the username, and I get redirected to 'userManagement.aspx?970fgb09fgdfg' - my question is, how am
I able to read that '970fgb09fgdfg' from the URL so that I can populate the new page with the correct information?
Any help on this matter is greatly appreciated.
Thanks :)
Oh and on a side-note, how do I get rid of these damn double-spaced lines when typing these forum posts without having to manually edit the HTML code?
Thanks for the quick replies guys. So in the column properties, i just change it from 'userManagement.aspx?{0}' where {0} is the UserID to 'userManagement.aspx?UserID={0}'?
Since u are using QueryStrings, then i would suggest you to have a look at this article:
http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx
I your case its almost ok....... because u have some complex user ID's..... but the user can have access to different Users by just changing the Value you pass through queryString...............
and regarding those doubled spaced lines........ just press Shift+Enter instead of Enter
Gurpreet Singh Dhaliwal
Marked as answer by schuminator on Mar 21, 2007 10:55 AM
hey Dhaliwal, thanks for the heads up. My UserID is a 'uniqueidentifier' from an SQL Database, so it's quite long and complex, but you can never be too careful. I've read that article and like what it says - I'll be sure to implement it (or something similar).
Thanks for your help, and thanks to the rest of you who replied. All of your replies were helpful :)
I'm loving the Shift+Enter thing...those double-spaced lines were getting annoying.
schuminator
Member
498 Points
214 Posts
Retrieve Value from URL
Mar 21, 2007 06:36 AM|LINK
I wasn't 100% sure where this thread belonged, so I put it in here.
I have a gridview whose data (UserID, UserName etc) is populated from an SQL Database. I have a hyperlink in this gridview so that you can click on a user's username and you get redirected to a separate page with a URL like userManagement.aspx?<userID> that is going to show information relative to that user (username, contact details etc) so that they can be updated.
At the moment, everything seems to be fine except I don't know how to use or retrieve the userID that is passed through in the URL. For example, I can click the username, and I get redirected to 'userManagement.aspx?970fgb09fgdfg' - my question is, how am I able to read that '970fgb09fgdfg' from the URL so that I can populate the new page with the correct information?
Any help on this matter is greatly appreciated.
Thanks :)
Oh and on a side-note, how do I get rid of these damn double-spaced lines when typing these forum posts without having to manually edit the HTML code?
Haissam
All-Star
37421 Points
5632 Posts
Re: Retrieve Value from URL
Mar 21, 2007 07:00 AM|LINK
You have to format your query string to look something like below
'userManagement.aspx?id=970fgb09fgdfg' Now in your code behind you always get the value of the id by using the below code
C#
string id = Request.QueryString["id"];
VB.NET
Dim id as string = Request.QueryString("id")
HC
MCAD.NET
| Blog |
AshokRaja
Contributor
2674 Points
478 Posts
Re: Retrieve Value from URL
Mar 21, 2007 07:05 AM|LINK
In the Tech.aspx page load check with the following code
if(Request.QueryString["Tab"] !=null){
Label1.Text = Request.QueryString["Tab"];
}
www.ashokraja.me
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
spvlong
Participant
1025 Points
187 Posts
Re: Retrieve Value from URL
Mar 21, 2007 07:10 AM|LINK
Hi schuminator,
You should pass UserId in URL like this: 'userManagement.aspx?UserID=970fgb09fgdfg'
In the userManagement.aspx page you can get the UserID with the code
string userId = Request.QueryString["UserID"];
Hope this helps
The Vietnamese Stock Market and Economy
schuminator
Member
498 Points
214 Posts
Re: Retrieve Value from URL
Mar 21, 2007 08:51 AM|LINK
Haissam
All-Star
37421 Points
5632 Posts
Re: Retrieve Value from URL
Mar 21, 2007 08:59 AM|LINK
Change it to 'userManagement.aspx?UserID={0} and use one of the code in the above posts to retrieve the value of UserID when needed.
HC
MCAD.NET
| Blog |
Dhaliwal
Participant
992 Points
231 Posts
Re: Retrieve Value from URL
Mar 21, 2007 09:07 AM|LINK
Since u are using QueryStrings, then i would suggest you to have a look at this article: http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx
I your case its almost ok....... because u have some complex user ID's..... but the user can have access to different Users by just changing the Value you pass through queryString...............
and regarding those doubled spaced lines........ just press Shift+Enter instead of Enter
schuminator
Member
498 Points
214 Posts
Re: Retrieve Value from URL
Mar 21, 2007 10:53 AM|LINK
hey Dhaliwal, thanks for the heads up. My UserID is a 'uniqueidentifier' from an SQL Database, so it's quite long and complex, but you can never be too careful. I've read that article and like what it says - I'll be sure to implement it (or something similar).
Thanks for your help, and thanks to the rest of you who replied. All of your replies were helpful :)
I'm loving the Shift+Enter thing...those double-spaced lines were getting annoying.
Cheers,
Ben