Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-04
2
Medium Priority
?
1,310 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 1000 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 1000 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

Technology Partners: 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

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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