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.

1
  • same scenario but with jQuery can be done using AjaxDropdown from here: awesome.codeplex.com Commented Feb 22, 2012 at 19:06

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.