I have several grids that I use to maintain records in tables. Several of these have a foreign key where I use a DropDownList to allow the user to select a name from the list rather than an ID. I have gotten all of this working great by using your examples. I basically have a UIHint on my property that specifies the partial view to use when editing/adding and item and I have partial views defined.
Like I said, everything is working great if I follow your examples and bind the DropDownLists to a collection in ViewData by using the .BindTo property on the DDL. Now I am trying to get away from using ViewData and I changed it to bind by using DataSource.Read and passing a controller and action but now there are no items in the list when I go to edit. The controller method is getting hit and results are being returned, it just never looks like anything actually gets loaded into the dropdown.
Here is my partial view with the DropDown:
And here is my controller method:
It is making it into the controller method and departments does have items in it.
Can anyone see anything obviously wrong or know of anything that might cause this behavior?
Thank you!
Like I said, everything is working great if I follow your examples and bind the DropDownLists to a collection in ViewData by using the .BindTo property on the DDL. Now I am trying to get away from using ViewData and I changed it to bind by using DataSource.Read and passing a controller and action but now there are no items in the list when I go to edit. The controller method is getting hit and results are being returned, it just never looks like anything actually gets loaded into the dropdown.
Here is my partial view with the DropDown:
@(
Html.Kendo().DropDownListFor(m => m)
.Name("Department")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetDepartments", "DepartmentMaintenance");
});
})
.DataValueField("DepartmentId")
.DataTextField("DepartmentName")
)
And here is my controller method:
//
// GET: /DepartmentMaintenance/GetDepartments
public
ActionResult GetDepartments([DataSourceRequest]
DataSourceRequest request)
{
var bll =
new
CatalogMaintenanceBll();
var departments = bll.GetDepartmentList(
false
);
return
Json(departments.ToDataSourceResult(request));
}
It is making it into the controller method and departments does have items in it.
Can anyone see anything obviously wrong or know of anything that might cause this behavior?
Thank you!