carmodyk
asked on
Cascading AJAX Dropdown list
Help! I'm trying to understand AJAX better, and unfortunately, I'm a newb at this. What I would like is to make a cascading dropdown list, but I'm using a SQL database to pull information from. Is there any example using VS 2005, VB.NET, AJAX and two dropdown lists and the northwind database to populate the dropdowns out there? I've been searching for miles and miles with nothing on the horizon.
Basically, this is what I want.
1. Populate the first dropdown
2. When the first dropdown index is changed, the second dropdown is pupulated with the sub info, hopefully without refreshing the whole page (Bah!)
Thanks so much.
Basically, this is what I want.
1. Populate the first dropdown
2. When the first dropdown index is changed, the second dropdown is pupulated with the sub info, hopefully without refreshing the whole page (Bah!)
Thanks so much.
Have you downloaded and installed ASP.Net AJAX yet? http://ajax.asp.net/
ASKER
Yep. I'm good to go on that.
You should be able to set up your SqlDataSource for the second control to accept the selected value of your first control as a parameter. ie "select name from models where make = @make" where @make is the selected value for the first dropdown.
ASKER
I'm sorry, I didn't make myself clear enough. I know how to populate another dropdown based on the value of the first drop down. What I want to do is do it in a way where the whole ASP page doesn't have to be refreshed. I've seen some examples, but most are in C#, I'm just curious if there is a VB.net example out there somewhere that can help me.
Sorry for the confusion.
Sorry for the confusion.
Carmodyk-
Check out this example from the ASP.NET AJAX AjaxControlToolkit:
http://ajax.asp.net/ajaxtoolkit/CascadingDropDown/CascadingDropDown.aspx
I think that illustrates exactly what you're after. Unfortunately, the source code for that demo is in C#. The C# code is very simple, though, and shouldn't be hard to convert to VB with an online tool. If you need help converting the C#, just let me know and I'll be happy to help.
Thanks~
Todd
Check out this example from the ASP.NET AJAX AjaxControlToolkit:
http://ajax.asp.net/ajaxtoolkit/CascadingDropDown/CascadingDropDown.aspx
I think that illustrates exactly what you're after. Unfortunately, the source code for that demo is in C#. The C# code is very simple, though, and shouldn't be hard to convert to VB with an online tool. If you need help converting the C#, just let me know and I'll be happy to help.
Thanks~
Todd
ASKER
Yes, I saw that, and it was very helpful as a starting point. However, I got confused when it came to importing data from a SQL database. (see following url: http://ajax.asp.net/ajaxtoolkit/Walkthrough/CCDWithDB.aspx)
If you follow the link, the part I got stuck on was this:
At runtime, the extender will make callbacks to a web service we specify (which is decorated with the Microsoft.Web.Script.Servi ces.Script Service attribute). In that web service, it expects a WebMethod with the following signature (note that parameter names must match too!):
What does that mean and what do I have to do to adjust to make this work from a database?
If you follow the link, the part I got stuck on was this:
At runtime, the extender will make callbacks to a web service we specify (which is decorated with the Microsoft.Web.Script.Servi
What does that mean and what do I have to do to adjust to make this work from a database?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm sorry ChrisPont, but this doesn't help me. I tried to convert your code to VB.net using some of the converters out there, but no avail. If you could explain the steps, I'm probably sure I can get this to work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Todd, Thanks for the assistance, but I'm having multiple errors with your code. First off, my program doesn't seem to like
Dim values As ListOf(AjaxControlToolkit. CascadingD ropDownNam eValue) = New ListOf(AjaxControlToolkit. CascadingD ropDownNam eValue)
Currently, I'm getting "Method Error 12031" What the heck is that!!!?!@
Dim values As ListOf(AjaxControlToolkit.
Currently, I'm getting "Method Error 12031" What the heck is that!!!?!@
Carmodyk-
No idea. The AjaxControlToolkit.Cascadi ngDrownDow nValue is a type that comes with the AjaxControlToolkit (obviously). Make sure you have the AjaxControlToolkit assembly in your project's bin folder before using this code or your project won't know what to do with these types.
Remember, all the webservice is doing is returning a list of values from the server to the next drop down in the hierarchy based on the selected value. The only part of this example that you must implement is:
<WebMethod()> _
Public Function yourNameHere(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.Cascadi ngDropDown NameValue( )
(Note the corrections I made to my original VB code). What you put in that function to build your CascadingDropDownNameValue list is completely up to you.
Thanks~
Todd
No idea. The AjaxControlToolkit.Cascadi
Remember, all the webservice is doing is returning a list of values from the server to the next drop down in the hierarchy based on the selected value. The only part of this example that you must implement is:
<WebMethod()> _
Public Function yourNameHere(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.Cascadi
(Note the corrections I made to my original VB code). What you put in that function to build your CascadingDropDownNameValue
Thanks~
Todd
ASKER
All right, I've got the errors to stop, but now I'm still having the same issues. I'm getting a "Method Error 12031" still coming up and I can't seem to find any reference to it. Any suggestions outside of using the Microsoft Toolkit example for cascading dropdown lists?
Sure! Did you say that you were open to 3rd party controls? If you are, there is a great example of this scenario using the r.a.d.combobox:
http://www.telerik.com/demos/aspnet/Combobox/Examples/Functionality/MultipleComboBoxes/DefaultVB.aspx
Not only is the example in VB, it does not require the complicated implementation of Web Services to work. Download the free trial of combobox here and give it a try:
http://www.telerik.com/products/aspnet/download.aspx
Let me know how that works for you. In the interest of transparency, I do work for Telerik, but hopefully our long discussion should make it evident that I am only interested in helping you find a working solution.
Thanks~
Todd
http://www.telerik.com/demos/aspnet/Combobox/Examples/Functionality/MultipleComboBoxes/DefaultVB.aspx
Not only is the example in VB, it does not require the complicated implementation of Web Services to work. Download the free trial of combobox here and give it a try:
http://www.telerik.com/products/aspnet/download.aspx
Let me know how that works for you. In the interest of transparency, I do work for Telerik, but hopefully our long discussion should make it evident that I am only interested in helping you find a working solution.
Thanks~
Todd
ASKER
:) I'm open to 3rd party controls, but not yet ready to shell out $800.00 just quite yet. If everyone is willing to give up, so am I.
Give up?
Let's try this:
How Do I: Use the ASP.NET AJAX CascadingDropDown Control Extender? (27 min. video)
http://www.asp.net/learn/videos/view.aspx?tabid=63&id=77
VB source code -is- available with this demo here:
http://download.microsoft.com/download/f/7/a/f7adf2b4-6554-4027-bac6-c853bc0a4f9d/HDI-AJAX-CascadingDropDown-VB.zip
Maybe that will help answer the outstanding questions with the AjaxControlToolkit. Also, with regards to the Telerik controls, I can make them less than $800 for you if you are interested. I don't want to violate this site's advertising restrictions, so let me know if you're interested and we talk about this specific item offline.
Thanks~
Todd
Let's try this:
How Do I: Use the ASP.NET AJAX CascadingDropDown Control Extender? (27 min. video)
http://www.asp.net/learn/videos/view.aspx?tabid=63&id=77
VB source code -is- available with this demo here:
http://download.microsoft.com/download/f/7/a/f7adf2b4-6554-4027-bac6-c853bc0a4f9d/HDI-AJAX-CascadingDropDown-VB.zip
Maybe that will help answer the outstanding questions with the AjaxControlToolkit. Also, with regards to the Telerik controls, I can make them less than $800 for you if you are interested. I don't want to violate this site's advertising restrictions, so let me know if you're interested and we talk about this specific item offline.
Thanks~
Todd
ASKER
Todd, thanks for all your input. I was able to use the VB.code and manipulate the example using your insert, so I know it works. Problem now is duplicating it. In my duplication, I'm still getting the error messages. Bah!
Thanks for the offer, I'll keep you in mind if I get any funds from work where I can purchase such things. Right now, not so much. :(
- Kevin
Thanks for the offer, I'll keep you in mind if I get any funds from work where I can purchase such things. Right now, not so much. :(
- Kevin
No problem. Good luck with the rest of your project.
Thanks~
Todd
Thanks~
Todd