Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP AND XML 3 30
JQuery on multiple lines 3 16
SP result not being displayed 5 44
.Net remove carriage returns, line feeds and tabbs 5 17
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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