Saturday, July 21, 2012

Cascading Dropdown in MOSS 2007

What is a Cascaded Dropdown?

A Cascaded dropdown is a combination of two dropdown lists. By selecting a value in the first one the options in the second get filtered according to its “parent” selection.
Sample uses:
Continents – Countries – Cities,
and many others ....

Solution :-

Download the Javascript here

Upload it to any document library in your site (assuming its hidden from users, you will not want users to modify it and give you a shock)

Right click on the javascript we just uploaded and click on "Copy Shortcut"

Now in the custom list New Form/Edit Form, add a Content Editor Webpart and make it hidden

Edit the WebPart properties and click on "Source Editor"

Paste the following line - 

void ParentDropDownList_SelectedIndexChanged(object sender, EventArgs e) 

     ChildDropDownListFieldControl child = (ChildDropDownListFieldControl)
               FindControlRecursive(this.Page, "ChildDropDownList").Parent.Parent; 
     child.SetDataSource(ParentDropDownList.SelectedValue); 
} 

There you go !!!
Hope this solution works for you.

No comments: