Solved

Trying to pass dropdownlist selected value in a querystring via asp hyperlink control

Posted on 2009-05-04
2
1,269 Views
Last Modified: 2013-11-07
I have a dropdown list control and an asp hyperlink. I want to be able to pass the selected value of the dropdown in the hyperlink when the user clicks the link. Have tried the following but to no avail...
int pid = Convert.ToInt32(ddlpartno.SelectedItem.Value);
lnkpartdetail.NavigateUrl = "~/production/pn_detail.aspx?partnoid_i=(pid)"

Open in new window

0
Comment
Question by:jazzcatone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 total points
ID: 24301543
int pid = Convert.ToInt32(ddlpartno.SelectedItem.Value);
lnkpartdetail.NavigateUrl = "~/production/pn_detail.aspx?partnoid_i=" & pid

OR

int pid = Convert.ToInt32(ddlpartno.SelectedItem.Value);
lnkpartdetail.NavigateUrl = "~/production/pn_detail.aspx?partnoid_i=(" & pid & ")"

0
 
LVL 29

Assisted Solution

by:David H.H.Lee
David H.H.Lee earned 250 total points
ID: 24311472
Hi jazzcatone,
A little bit of modification for pratima_mcs proposed if you're running under code-behind. It should be "+" sign instead of "&" sign during append the string in c# environment.
eg:
int pid = Convert.ToInt32(ddlpartno.SelectedItem.Value);
lnkpartdetail.NavigateUrl = "~/production/pn_detail.aspx?partnoid_i=" + pid;

If you're running under client script, try this alternative solution:

page_load event
============
if(!IsPostBack){
  lnkpartdetail.attributes.add("onClick","javascript:NavigateURL('~/production/pn_detail.aspx?partnoid_i=') ;return false;");
}

<script>
function NavigateURL(strURL){
 var objDrp=document.getElementById('<%= ddlpartno.ClientId%>');

 if(objDrp.selectedIndex>0){
    location.href=strURL + objDrp.value;
 }
}
</script>


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question