vbnetdev
asked on
Gridview Hyperlink value. Need to pass to another page but not using QueryString.
On btnSearch_Click event I bind the gridview. First column "Name" is the hyperlink and the second column "UserID" value I need to pass to another page but NOT using Request.QueryString.
Here is the visual of bind datagrid:
Full Name...................... ..User ID....................Head er title.................
Joe, Doe ........................12 3456...... .......... ...other cell values ..........
Jane, Doe....................... .78910.... .......... .......oth er cell values..........
The grid might contain a single row or hundreds of rows.
Based on the code below I'm getting hyperlink href="nextpage.aspx?id=y&u serid=1234 5" and so on. However, I need the following:
a. Hide the userid value so the user just sees "nextpage.aspx?id=y"
b. Pass userid value to the next page when user clicks on the link.
Should I use session variable, hidden fields or what? But how? Example please.
Here is the visual of bind datagrid:
Full Name......................
Joe, Doe ........................12
Jane, Doe.......................
The grid might contain a single row or hundreds of rows.
Based on the code below I'm getting hyperlink href="nextpage.aspx?id=y&u
a. Hide the userid value so the user just sees "nextpage.aspx?id=y"
b. Pass userid value to the next page when user clicks on the link.
Should I use session variable, hidden fields or what? But how? Example please.
<asp:gridview ID="gvGetUser" AutoGenerateColumns="false"..../>
<columns>
<asp:hyperlinkfield DataTextField="Name" HeaderText="Full Name" ItemStyle-HorizontalAlign="left" ControlStyle-CssClass="lnk"
DataNavigateUrlFields="UserID" DataNavigateUrlFormatString="nextpage.aspx?id=y&userid={0}" />
<asp:boundfield DataField="UserID" HeaderText="User ID" />
....
</columns>
</asp:gridview>
ASKER
Yes, the user should NOT see the user id when mouse over the link (1st page) along with when the next page loads. And if using session variable, how would I set an individual user id into session or encrypt the value if datagrid might contrain more then 1 row. The user would click only one (user id) at the time and I need an example how to set the value into session since I don't know which link the user clicks. This userid value I need to pass to the next page and run another stored procedure as a passed parameter.
Hope it's clear.
Hope it's clear.
ASKER
Maybe i should set a button with CommandName="Select" first. That way I will know which row the user selected. Then when the row is selected, grab "UserID" value, set into session variable and redirect to the next page.
Anybody else? Surprised just 1 person responded.
Anybody else? Surprised just 1 person responded.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks but it complained about (Containter.DataItem, "userid") under CommandArgument.
I decided to give a different approach.
User clicks search button to get the grid fill with hyperlink as one of the columns.
a. On button_Click event I create a hashtable, bind the grid and add hastable into Session variable.
b. Under _RowDataBound grid event I create a NewGuid, add NewGuid as a key with "userid" value.
c. Then programmatically create a hyperlink with .NavigateUrl set to "nextpage.aspx?guid=" + guid.toString
d. I keep UI hyperlink column just with DataTextField, HeaderText and ControlStyle-CssClass
e. Nextpage.aspx page will read Session varialble and grabs assigned UserID value based on matched guid received through QueryString.
I decided to give a different approach.
User clicks search button to get the grid fill with hyperlink as one of the columns.
a. On button_Click event I create a hashtable, bind the grid and add hastable into Session variable.
b. Under _RowDataBound grid event I create a NewGuid, add NewGuid as a key with "userid" value.
c. Then programmatically create a hyperlink with .NavigateUrl set to "nextpage.aspx?guid=" + guid.toString
d. I keep UI hyperlink column just with DataTextField, HeaderText and ControlStyle-CssClass
e. Nextpage.aspx page will read Session varialble and grabs assigned UserID value based on matched guid received through QueryString.
or you should encrypt the url and decrypt it in the next page.