Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 5th, 2009, 01:51 AM
Authorized User
Points: 239, Level: 4
Points: 239, Level: 4 Points: 239, Level: 4 Points: 239, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
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.
  #2 (permalink)  
Old May 5th, 2009, 03:38 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!
  #3 (permalink)  
Old May 5th, 2009, 10:51 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

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">
   <title>Parts</title>
</head>
<body>
   <form id="form1" runat="server">
      <div>
         Part No:
         <asp:DropDownList ID="ddlpartno" runat="server" AutoPostBack="True">
            <asp:ListItem Text="part1" />
            <asp:ListItem Text="part2" />
            <asp:ListItem Text="part3" />
         </asp:DropDownList>
         <p>
            <asp:HyperLink ID="lnkpartdetail" runat="server">Part Details</asp:HyperLink>
         </p>
      </div>
   </form>
</body>
</html>
Code:
using System;

public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      lnkpartdetail.NavigateUrl =
         String.Format(
            "~production/pn_detail.aspx?pnpartnumber={0}",
            ddlpartno.SelectedValue);
   }
}
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #4 (permalink)  
Old May 5th, 2009, 07:05 PM
Authorized User
Points: 239, Level: 4
Points: 239, Level: 4 Points: 239, Level: 4 Points: 239, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. I really appreciate your input.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:14 AM.


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