我想从操作方法填充下拉列表。当我第一次加载视图时它工作得很好,但是当我重新加载视图时它不会再次调用该操作。
问题是如果我从数据库中删除一个项目,下拉列表不会刷新结果。
我的观点:
@(Html.Kendo().DropDownListFor(model => model.IdSistema)
.Name("ddlSystems")
.OptionLabel("<.. Select an item ..>")
.DataTextField("DescSys")
.DataValueField("Id")
.HtmlAttributes(new { Style = "Width:243px;" })
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetAllSystems", "Systems");
})
.ServerFiltering(true);
})
.SelectedIndex(0)
)
我的控制器:
public JsonResult GetAllSystems([DataSourceRequest] DataSourceRequest request)
{
var items = (from row in _SystemService.GetAll()
orderby row.DescSys
select new { row.Id, row.DescSys });
return Json(items, JsonRequestBehavior.AllowGet);
}
谢谢你帮助我。