アクション メソッドからドロップダウン リストを設定したい。初めてビューを読み込んだときはうまくいきますが、ビューをリロードするとアクションが再度呼び出されません。
問題は、データベースから項目を削除すると、ドロップダウン リストが結果を更新しないことです。
私の見解:
@(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);
}
私を助けてくれてありがとう。