This is a migrated thread and some comments may be shown as answers.

kendo Dropdown list throwing bindto error

1 Answer 274 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 1
Vivek asked on 13 Mar 2013, 03:29 AM
Hi Guys, 

I am getting an error in dropdown list. 

Overload resolution failed because no Public 'BindTo' is most specific for these arguments:
    'Public Function BindTo(dataSource As System.Collections.Generic.IEnumerable(Of SelectListItem)) As Kendo.Mvc.UI.Fluent.DropDownListBuilder':
        Not most specific.
    'Public Function BindTo(dataSource As System.Collections.Generic.IEnumerable(Of DropDownListItem)) As Kendo.Mvc.UI.Fluent.DropDownListBuilder':
        Not most specific.

This is the line where this exception is being thrown at:

    <div class="editor-field">
        @(Html.Kendo().DropDownList().Name("ExternalMailItemID").BindTo(ViewData("ExternalMailItem")))       
        @Html.ValidationMessageFor(Function(model) model.ExternalMailItemID)
        </div>

This is what i am doing in the controller:

   <HttpPost()> _
        Function Create(ByVal collection As ExternalMailCost) As ActionResult
            Try
                If _repositoryForMailItem.IsExternalMailItemExist(collection.ExternalMailItemID, collection.StartDate, collection.EndDate) = True Then
                    ModelState.AddModelError("", "Unable to add record. There is an overlapping record for this mail item")
                End If


                If ModelState.IsValid Then

                    'Check whether a cost has already been associated with the same mail item
                    ' if there is already cost associated, then check whether the dates selected overlapse?

                    _repositoryForMailCost.Save(collection, "VivekBa")
                End If
                Return View()

            Catch
                Return View()
            End Try
        End Function

The error is thrown when i add the error in the addmodelerror, otherwise it works fine. please help

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 13 Mar 2013, 08:19 AM
Hi Vivek,

 The compiler error means that the BindTo method requires IEnumerable. As you know ViewData("ExternalMailItem") returns Object hence the compilation error. You need to cast it first.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Vivek
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or