Solved

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

Posted on 2009-05-04
2
1,182 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now