CascadingDropDown SelectedValue.Text

by Nate on November 26, 2006

A quick one: Up until this latest version of the ASP.NET Ajax extensions, one of the glaring “bugs” (if you want to call it that) with the CascadingDropDown control was that it returned the backend value of the dropdown rather than the actual selected display value. This caused problems when trying to access the SelectedValue. The only way to quasi-cleanly work around this was to manually edit the associated javascript.

Well, I just found out that this problem was addressed in the latest release. You can now access the SelectedValue of a CascadingDropDown control without having to implement a messy workaround:

ddlCars.SelectedItem.Text

Not anything ground-breaking, but a very welcome fix.

Listening to Broken Social Scene – You Forgot It in People
My Nose is In Daniel Quinn – Ishamel

{ 4 comments… read them below or add one }

Shigg May 2, 2007 at 7:41 pm

I don’t know what you’re talking about. CascadingDropDown controls don’t have a SelectedItem property and accessing the SelectedItem.Text property on the associated DropDownList doesn’t get the most recent selection.

Reply

Nate June 16, 2007 at 2:05 am

You’re right. The CascadingDropDown control doesn’t have a SelectedItem property, but the associated DropDownList control does. And I have found that the SelectedItem.Text property on the associated DropDownList gets the selected value with ASP.NET AJAX Extensions (at the time that I wrote the article, still “Atlas” RC1) and up. I’ve implemented it, and am using it in several different applications.

Guess we’ll have to agree to disagree.

Reply

Tome July 18, 2007 at 8:07 pm

On what event of control can i set ddlCars.SelectedItem.Text

Reply

Nate July 30, 2007 at 8:53 pm

You can access the SelectedItem.Text value using just about any event that you want, including the on change event. I often use a button click event, but there are numerous ways to do it, obviously depending on what you’re looking to do.

Reply

Leave a Comment

Previous post:

Next post: