Showing posts with label cascading. Show all posts
Showing posts with label cascading. Show all posts

Wednesday, March 28, 2012

How do I Select Values in Cascading Dropdowns

Using VS 2005, ASP.NET AJAX 1.0 and AJAX Toolkit 10618

I have 2 dropdowns using the Cascading Dropdown from the toolkit, these are both connected to a web service and this all seems to work fine. No other Ajax type controls are being used on the page.

How do I set the dropdown values from server side code? or any method to change the selected item in each dropdown once they have been set.

I did manage to get the selected value to pass in with the data from the callbacks on the web service and this works fine when the page first opens, but any attempt to change the selected values once the page is open either through the web service or server code does not work; both drop downs keep their previous setting. I have setup a breakpoint on the data (in the web service) before it is sent back to the page and I can see the item that should be selected but yet the dropdowns do not change their selected value.

I have tried combobox.selectedvalue = "Some Value" and the GetTargetProperties method doesn't seem available anymore.

I have this nagging suspicious feeling I am missing something obvious.

Please Help

This video has a walk though.

http://asp.net/learn/videos/view.aspx?tabid=63&id=77


I had used the information in this video to get started which was a great help.

Now I need to now how to set a selected value in the dropdowns. I can get the values set on the initial page load, it is changing the values once the page is loaded and the initail values have been set. The setting of the selected values are done through code. It seems that the dropdowns have a memory once their intial selected values are set and cannot be changed.


figured it out!

Had a look at the toolkit source code and it was obvious...

cascadingdropdown1.clientstate = "String of selected value"

All is good in the world again!


Turns out SelectedValue works as well. I was trying to do this on the dropdown itself instead of the cascading control.

Wednesday, March 21, 2012

How can I modify the AJAX Cascading Dropdownlist to use a Listbox as the last control

Hello - I have a need to modify the AJAX Cascading Dropdownlist where the last control is a listbox.

Just changing the last control to a listbox won't do it since I get the following error:

Unable to cast object of type 'System.Web.UI.WebControls.ListBox' to type 'System.Web.UI.WebControls.DropDownList'

To me it looks like the CascadingDropdownExtender.cs file would need to be modified but I am not sure where to start

The problem is that the targetcontrol on the extender is set to DropDownList instead ListControl which is more inclusive. You couldopen a work item for this and we will look into fixing this.