tags:

views:

449

answers:

1

I have three dropdown list each dependent on previous one.

How it is possible by using MicrosoftAjax & web services?

I also want selected value in Edit view.

I have seen tip41 of stephen walther.

But i have error on each view i.e.

 <%= Html.DropDownList("--Select Make--", "Makes") %>

that CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'DropDownList' and no extension method 'DropDownList' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)

So what would be reason? i am using MVC 1.0.

A: 

I think you have the name/option label turned around. You might also want to try using the signature with the value parameter in it. I'm not sure why you were having a compile problem, however, since there is a version of the extension that takes two string parameters. Docs can be found at MSDN.

<%= Html.DropDownList( "Makes",
                       "--Select Make--" ) %>

OR

<%= Html.DropDownList( "Makes",
                       (IEnumerable<SelectListItem>)ViewData["Makes"],
                       "--Select Make--" ) %>

For cascading dropdowns, you might want to use jQuery instead and get JSON key-value pairs for the next menu based on the selection in the first one. Add an onChange handler to the selects and do an AJAX get/post to an action in your controller to get the new values. I construct a list of key value pairs and return that in a JsonResult. In the success handler of the ajax query, I take that result and replace the contents of the appropriate select with new options using the returned JSON.

tvanfosson