chowe991
chowe991

Reputation: 59

Kendo UI DropDownList Problems - MVC Razor

@(Html.Kendo().DropDownListFor(m => m.PackageId)
                                              .OptionLabel("Select a Package...")
                                              .Name("PackageId")
                                              .DataValueField("PackageId")
                                              .DataTextField("PackageName")
                                              .BindTo(Model.ListOfTenantPackages)
                                              .Template("<div class=\"k-state-default\">#:data.PackageName#</div><div class=\"k-state-default\">#:data.PackageValue #</div><div class=\"k-state-default\">#:data.PackageDescription #</div>")
                                              .HtmlAttributes(new { @class="drop-down col-lg-6 col-md-6", onchange = "update_preview()"}))

This is the code that I have for my Kendo dropdown list. On the post back, I'm getting the package name as the value of the selected item instead of the package ID. Why?

Upvotes: 0

Views: 450

Answers (1)

Charmless
Charmless

Reputation: 61

Try removing the

.Name("PackageId")

line.

You don't need to specify the Name for the DropDownListFor<> to work

Upvotes: 1

Related Questions