Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 3.5 Website Programming Problem Design Solution
This is the forum to discuss the Wrox book ASP.NET 3.5 Website Programming Problem Design Solution by Chris Love; ISBN: 978-0-470-18758-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Website Programming Problem Design Solution 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 Display Modes
  #1 (permalink)  
Old June 11th, 2010, 04:42 AM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default Need to create multiple dropdown list

I need to create several dropdown lists where based on choosing one item in a dropdown list, the next dropdown item gets chosen and so on. These items can come from database as well. Anybody knows of any existing source code?
  #2 (permalink)  
Old June 14th, 2010, 04:59 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Hi there,

You could take a look at the CascadingDropDown control in the AJAX Control Toolkit: http://www.google.nl/#hl=nl&q=ajax+c...ce7b8b40a10917

Cheers,

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 June 14th, 2010, 02:49 PM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thanks, but, what I wanted is to have the second and 3rd dropdown show up when an item from 1st dropdown is selcted.
  #4 (permalink)  
Old June 14th, 2010, 02:55 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Isn't that exactly what the CascadingDropDown is supposed to do? If not, can you elaborate?

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!
  #5 (permalink)  
Old June 14th, 2010, 06:30 PM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Not really. Even though it's cascading dropdown, from the examples, you select car's make and then model, etc. All three of the dropdown controls are shown already. What I want to do is select from first control for make and then based on that make(such as BMW) second dropdown is visible and shows the choices for BMW(such as 328i, etc.)I don't really want any control to show up below(just invisible) unless I selected BMW or something. Maybe JQuery can do that, but, without JQuery is it possible to do other ways?
  #6 (permalink)  
Old June 15th, 2010, 03:27 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Isn't that simply a matter of hiding the second and third control at first by setting Visible to false and showing them only when their DataBound event is fired?

But there are many solutions outside the CascadingDropDown (which really makes things a lot simpeler).

1. Use your own code server side
Set AutoPostBack on the first DDL to true. In it SelectedIndexChanged event get the selected item, get relevant items from the database and bind them to DDL2. Additionally, show DDL2. Repeat that for the combination of the second / third DDL.

2. Use jQuery and AJAX calls and build up the list client side
A lot has been written about this so you may want to Google a bit until you find an article you like and can use. Here's a start: http://www.dotnetcurry.com/ShowArticle.aspx?ID=417

3. Use third party controls
Commercial software vendors often have controls for this scenario. Again, Google should bring up useful stuff.

Cheers,

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!
  #7 (permalink)  
Old June 15th, 2010, 07:36 PM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I chose your suggested solution #2 because, that sounded more straightforward and quick. But, I'm getting some JavaScript error which is preventing me to run this successfully:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.

Source Error:


Line 1:
Line 2: <head>
Line 3: <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
Line 4: <script language="javascript" type="text/javascript">
Line 5: $(function () {


Source File: /Default.aspx Line: 3


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

-------

I placed the script code in the default.aspx with <head>..</head> enclosed.
  #8 (permalink)  
Old June 16th, 2010, 04:17 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Quote:
I placed the script code in the default.aspx with <head>..</head> enclosed.
That's not allowed when the page is based on a master page. You can choose among at least three solution:

1. Don't use a Master Page

2. Move the script to the <head> section of the Master Page (so it's available in all pages that use that master page)

3. Create a ContentPlaceHolder in the head of the master and add the scripts to the Content block for that ContentPlaceHolder in your content page.

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!
  #9 (permalink)  
Old June 17th, 2010, 10:30 PM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I think I already tried the third option that you've stated. That didn't work with default asp container. I'll try the 2nd one.
  #10 (permalink)  
Old June 18th, 2010, 03:48 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,050
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

The third option should definitely work; it's what I always use for these scenarios. What error are you getting or why doesn't it work for you?

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!
 


Thread Tools
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
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 01:32 AM
Dropdown list with multiple selections tombert ASP.NET 1.0 and 1.1 Basics 15 March 7th, 2007 07:38 PM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 06:41 AM
Storing multiple values from the dropdown list lily611 SQL Server 2000 0 June 21st, 2004 07:08 AM
Storing multiple values from the dropdown list lily611 ADO.NET 0 June 21st, 2004 06:21 AM



All times are GMT -4. The time now is 02:08 PM.


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