0
我嘗試了簡單的ASP.NET MVC2下拉列表,但從tryupdatemodel下面得到錯誤。如何修復MVC2下拉列表中的轉換錯誤
如何解決這個問題,everthing看起來正確?
觀點:
<%= Html.DropDownList("Post24DeliveryPlaces", Model.DeliveryPlace)%>
型號:
public IEnumerable<SelectListItem> Post24DeliveryPlaces { get; set; }
public string DeliveryPlace { get; set; }
結果:
System.InvalidOperationException: The parameter conversion from type 'System.String' to type 'System.Web.Mvc.SelectListItem' failed because no type converter can convert between these types.
at System.Web.Mvc.ValueProviderResult.ConvertSimpleType(CultureInfo culture, Object value, Type destinationType)
at System.Web.Mvc.ValueProviderResult.UnwrapPossibleArrayType(CultureInfo culture, Object value, Type destinationType)
at System.Web.Mvc.ValueProviderResult.ConvertTo(Type type, CultureInfo culture) at System.Web.Mvc.DefaultModelBinder.ConvertProviderResult(ModelStateDictionary modelState, String modelStateKey, ValueProviderResult valueProviderResult, Type destinationType