Reputation: 253
I am looking for the best solution for my problem. I am currently using a asp.net gridview with a link in the first column and the id to the item it relates too.
Details href=.../page.aspx?ID=25
I have 3 hidden fields that I would like to bring with me to the next page.
I want the url to look something like this. Details href=.../page.aspx?ID=25&HDN1=3&HDN2=5&HDN3=76
I am able to set the values of the hidden text. I need to retrieve the values and add them to the url in the Details link.(onclick?). What is the best way to get this done??
Upvotes: 0
Views: 5818
Reputation: 7713
If these hidden fields are part of the databinding source collection then you can pass multiple parameters to a HyperLinkField GridView column. eg:
<asp:HyperLinkField DataNavigateUrlFields="id, field1, field2" DataNavigateUrlFormatString="/page.aspx?id={0}&hdn1={1}&hdn3={2}" />
Edit:
OK if it's client side, then you will have to do this via javascript.
I would add an onclick handler to each of your links:
<a href="details.aspx?id=123" onclick="detailsHandler(this.href); return false;" />
then a javascript function to handle the redirect:
function detailsHandler(href) {
var hiddenField = document.getElementById('eleID').value;
//get any other hidden fields and append them.
href = href + "&hnd1=" + hiddenfield;
//then redirect to the revised url
window.location = href;
}
Upvotes: 1