Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 5th, 2009, 01:51 AM
Authorized User
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trying to pass SelectedValue of dropdown in querystring.

I have a dropdown control and a hyperlink control. Am trying to pass the SelectedValue of the dropdown when the user clicks the hyperlink control. Code is below:

string pid = ddlpartno.SelectedItem.Value;
lnkpartdetail.NavigateUrl =
"~/production/pn_detail.aspx?pnpartnumber=" & pid;

Any idea what i need to do. Seems I get Intellisense errors in VS no matter what I try. Any advice would be greatly appreciated.
Old May 5th, 2009, 03:38 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

What error do you get? Often, posting the right error message leads to a quicker solution...

In this case, I can see one thing wrong:

"~/production/pn_detail.aspx?pnpartnumber=" & pid;

In C#, you shouldn't use the ampersand, but a plus:

"~/production/pn_detail.aspx?pnpartnumber=" + pid;

Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Old May 5th, 2009, 10:51 AM
Lee Dumond's Avatar
Wrox Author
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts

HTML Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
   Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <form id="form1" runat="server">
         Part No:
         <asp:DropDownList ID="ddlpartno" runat="server" AutoPostBack="True">
            <asp:ListItem Text="part1" />
            <asp:ListItem Text="part2" />
            <asp:ListItem Text="part3" />
            <asp:HyperLink ID="lnkpartdetail" runat="server">Part Details</asp:HyperLink>
using System;

public partial class _Default : System.Web.UI.Page
   protected void Page_Load(object sender, EventArgs e)
      lnkpartdetail.NavigateUrl =
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

if (this.PostHelpedYou)
Old May 5th, 2009, 07:05 PM
Authorized User
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks. I really appreciate your input.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass QueryString to DDL then run refresh sterreyl ASP.NET 2.0 Basics 2 March 20th, 2007 10:49 AM
Pass value from dropdown list to another ASP SQL Thamil BOOK: Professional Crystal Reports for VS.NET 0 August 25th, 2006 04:18 AM
How do I pass URL to querystring? Shawn Mohan .NET Web Services 0 June 28th, 2006 12:33 AM
how to pass a value in querystring lian_a Classic ASP Basics 1 July 9th, 2004 03:21 AM
How to pass plus (+) character in querystring marjorin Classic ASP Professional 4 October 31st, 2003 04:40 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.