[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Cascading DropDownList fill using DAL

Posted on 2012-04-05
16
Medium Priority
?
472 Views
Last Modified: 2012-04-12
I have a DAL (data access layer) that is feeding a few cascading ASP.NET DDL (DropDownLists) using a DataReader and Stored Procedures.

When a user selects an item:

1.

A different DDL is filled with data

2.

Each list item of all DDLs immediately displays its image in a shared ImagePlaceHolder when selected by the user. The current image replaces the previous image.
Hope you can help, thanks.
0
Comment
Question by:mitdaniels
[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
  • 8
  • 8
16 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37815410
What is your question?
0
 

Author Comment

by:mitdaniels
ID: 37816921
How do I do this using C# ASP.NET in a web application?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37817117
Are you using the CascadingDropdown controls from the AJAX Control Toolkit, or the standard ASP.NET DropDownList controls?  

Are the images coming from file, database, ...?

How much detail do you need to figure this out?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:mitdaniels
ID: 37818114
I am using standard ASP.NET DropDownLists, the images' name (imagename.jpg) is coming from the database, so just a string.

I need to know how you would fill the DDL via the stored procedure, especially given that I am using a DAL, so a new custom database object gets instantiated on the mypage.aspx.cs page and take it from there. I don't want to use the ObjectDataSource or any automated type tool, just simple classes and objects. I am using a DataReader, no Dataset or any of its features.

How many different stored procedures do you use and why would be helpful.

The main section of interest though is how you'd go about getting the DDLs and images to work well.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37819118
Will the DropDownList have a display and a value, like Display=Washington, and Value=WA?  Will you select the DropDownList, and use the "value" to determine which file name to display?  You can build a list of business objects, or a list of KeyValuePair<string, string>, and then bind the DropDownList's DataTextField and DataValueField to the matching properties.
0
 

Author Comment

by:mitdaniels
ID: 37819212
I am not sure whether this will answer your question, but the values from each DDL are not unique to each list, so you could have the same value in the next list.

The images to display are a result of either a single or combination of previous DDL selections.

The first DDL will have say 5 colors, and each will have an image of its own to display. The first list will also fill another list with company names and each of those when selected will have an image to display. In addition, the first list will fill another list with colors, and each of them will do the same as the first DDL.

This goes down a few levels, but if I can see how the first two levels could work, the rest will not be a problem.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37819588
Within a single DropDownList, you need unique values.  Across multiple DropDownList controls, you can have duplicate values.

Can you show me an example of the display text and values for each DropDownList in the cascade?
0
 

Author Comment

by:mitdaniels
ID: 37819771
Yes, unique in a single DDL, but the other DDLs could have some of the same values. They're just colors (black, white, red, blue, gold, dark blue, etc...). The display is only the image, and the values into DDLs. The company name DDL values are company names (Microsoft Inc, Apple, Wendys, AAA, etc...).
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37819949
Something like this, where you take each selection and make up an image file name for an <asp:Image> control?

DDL #1
---------
Black
White
Red
Blue
Gold
Dark Blue

DDL #2
---------
Microsoft
Apple
Wendy's
AAA

Image files
---------------
Blue Microsoft.jpg
Black Apple.jpg
Red AAA.jpg
0
 

Author Comment

by:mitdaniels
ID: 37821766
Yes, so when DDL #1 is loaded, the first value is automatically selected (Black in your example), and the companies related to "Black" would be loaded automatically into DDL #2, and the first selected value of DDL #2 (Blue Microsoft.jpg in your example) would have its image display in an <asp:Image> control on the same page. So each listed company would have a related image displayed when selected.

Remember that another DDL is filled with the next level of colors, and this DDL would do the same thing DDL #1 has done when the user selects any of its colors (values).

In some cases DDL#1 would not have a list of companies related to it, so there would be an empty DDL#2, and an image placeholder would display in the same <asp:Image> control.  saying something like "No image to display". However it definitely has a valid image at one of the levels lower down, and this depends on the color combination found in the database.

Keep in mind that you'll have color DDLs (representing levels / color combinations), just 1 DDL for listing companies (fill the same one with new data at each color level)  and just 1 <asp:Image> control that displays 1 image at a time.

Each company has a specific image that is unique to it, like a logo for example.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37822199
DropDownList #1 selection is a filter criteria for DropDownList #2.  When you select a value for DropDownList, then display an image...

Attach an event handler to the DropDownList2.SelectedIndexChanged event.  Determine the selected value from DDL #1 and DDL #2, and use that to generate a file  name for the Image control.  Make sure that DDL2.AutoPostBack = true.
0
 

Author Comment

by:mitdaniels
ID: 37840650
Sorry for the delay, been busy moving.

I think it might be better if I were to ask specific questions and award your points based on that.

I've already done everything we've discussed before posting this "question", so it feels like we're going over unnecessary things, though it might be important information that will help you understand what I am doing.

So I still have the problem of trying to make a cascading dropdownlist work effectively, and to make things easier, I'll ask this specific question, and award points accordingly:

The default Visible property of each, but the first, dropdownlist is set to false, and as each related Color DDL, Company DDL, and Image control is filled, their Visible property is set to "True", as one might expect.

This occurs for the various levels between 1 and 4 levels. The problem is that if for example all 4 DDLs levels are now visible due to valid selections, the user can now decide to select what happens to be just a 2 level color scheme, and thereby leaving 2 visible DDLs that are irrelevant to the current 2 level selection.

I am not sure at which point I should set the DDLs visibility property False again. Since I won't know what the user will do after the DDLs are visible, there has to be a point at which I can set all DDLs visibility property to false if the user decides on a new set of selections irrespective from which DDL level the user decides to make a new selection.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 37840716
So, you are asking for a logic flow, rather than a coding question...

I believe that you are describing a scenario that I usually see with product selectors, like this one:

http://www.tirerack.com/

1) Select Make from first drop-down

2) Show the Year drop-down.  

3) Select the Year

4) Show the Model drop-down

If you select a different Make, the page hides the Model drop-down, and resets the Year drop-down to "Select a Year".  This is the way that I see as the expected behavior for cascading drop-downs.

Have you looked at the CascadingDropDown controls that come with the AJAX Control Toolkit?
0
 

Author Comment

by:mitdaniels
ID: 37840753
Initially this task looked very easy, but it turns out that there is a high degree of complexity to overcome with this particular set of dropdownlists and data.

I'll have to take your advice and look at other websites and also perhaps see how they do it with Ajax.

Thanks for your time and effort, appreciate it.
0
 

Author Closing Comment

by:mitdaniels
ID: 37840756
Thanks again!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37840800
I find that browser developer tools really help your detective work, especially what you get with Google Chrome, since they can really help you examine the specifics about how a web site works.  Internet Explorer and FireFox also have developer tools.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

656 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