"The call is ambiguous between the following methods or properties" MVC 3 Telerik Drodownlist

While working on my project i suddenly got this error...


The call is ambiguous between the following methods or properties: 'Telerik.Web.Mvc.UI.Fluent.DropDownBuilderBase<Telerik.Web.Mvc.UI.DropDownList,Telerik.Web.Mvc.UI.Fluent.DropDownListBuilder>.BindTo(System.Collections.Generic.IEnumerable<Telerik.Web.Mvc.UI.DropDownItem>)' and 'Telerik.Web.Mvc.UI.Fluent.DropDownBuilderBase<Telerik.Web.Mvc.UI.DropDownList,Telerik.Web.Mvc.UI.Fluent.DropDownListBuilder>.BindTo(System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>)'

After spending few mints on tracking this issue i get it solved.This error comes when you DO NOT provide the data to the view from the Controller.  In my case here is the code that work for me.

Just provide all the things used in View like ViewBag,ViewData etc etc.

public ActionResult Index(FormCollection formValues)
        {
            var CountryList = GetCountryList();
            ViewBag.AllCountryList = CountryList ;

            return View();
        }

 @(Html.Telerik().DropDownList()
            .Name("ddlCountries")
            .ClientEvents(events => events
                          .OnChange("onDropDownListChange")
                          )
            .SelectedIndex(0)
            .BindTo(ViewBag. CountryList )
            .HtmlAttributes(new { style = string.Format("width:{0}px", 80) })
    )


Note: This solution work for me successfully. You may have to search more if you failed.

Comments

Post a Comment

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

Download file failed signature verification and may have been tampered with - Workflow Manger 1.0 Refresh (CU2)