when nested collection model binding to Kendo DropDownList,
not bind correctly .
Kendo.Mvc version is 2013.1.319.340
HomeControoler.cs
Index.cshtml
result
not bind correctly .
Kendo.Mvc version is 2013.1.319.340
HomeControoler.cs
namespace MvcApplication5.Controllers
{
public class ChildModel
{
public int CategoryId { get; set; }
}
public class ParentModel
{
public int CategoryId { get; set; }
public ChildModel Child { get; set; }
public List<
ChildModel
> Children { get; set; }
}
public class HomeController : Controller
{
public ActionResult Index()
{
var model = new ParentModel
{
CategoryId = 2,
Child = new ChildModel { CategoryId = 2},
Children = new List<
ChildModel
>
{
new ChildModel { CategoryId = 2}
}
};
return View(model);
}
}
}
@model MvcApplication5.Controllers.ParentModel
@{
ViewBag.Title = "Index";
var list = new List<
SelectListItem
>()
{
new SelectListItem() { Value = "1", Text = "one" },
new SelectListItem() { Value = "2", Text = "two" },
new SelectListItem() { Value = "3", Text = "three" },
};
}
<
h2
>all actual categoryid must be 2</
h2
>
<
h3
>[OK] Model.CategoryId: @Model.CategoryId</
h3
>
@(Html.Kendo().DropDownListFor(m => m.CategoryId)
.BindTo(list)
)
<
h3
>[OK] Model.CategoryId: @Model.Child.CategoryId</
h3
>
@(Html.Kendo().DropDownListFor(m => m.Child.CategoryId)
.BindTo(list)
)
<
h3
>[NG] Model.Children[0].CategoryId: @Model.Children[0].CategoryId</
h3
>
@(Html.Kendo().DropDownListFor(m => m.Children[0].CategoryId)
.BindTo(list)
)
<
hr
/>
@Html.TextBoxFor(m => m.Children[0].CategoryId)