Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

772 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