Kendo ui Kendo ui mvc dropdownlistfor使用实体框架具有布尔类型值
我正在使用实体crud操作,并且Kendo ui Kendo ui mvc dropdownlistfor使用实体框架具有布尔类型值,kendo-ui,kendo-asp.net-mvc,kendo-treeview,kendo-ui-mvc,Kendo Ui,Kendo Asp.net Mvc,Kendo Treeview,Kendo Ui Mvc,我正在使用实体crud操作,并且处于活动状态是一个布尔类型的值。在生成编辑视图时,它会显示下拉列表,其中列出了要编辑的代码 @Html.Kendo().DropDownListFor(model => model.Is_Active) //instead of @Html.EditorFor(model => model.Is_Active)" 我想在剑道ui中使用 @Html.EditorFor(model => model.Is_Active) 但它显示的是空白下
处于活动状态
是一个布尔类型的值。在生成编辑视图时,它会显示下拉列表,其中列出了要编辑的代码
@Html.Kendo().DropDownListFor(model => model.Is_Active)
//instead of @Html.EditorFor(model => model.Is_Active)"
我想在剑道ui中使用
@Html.EditorFor(model => model.Is_Active)
但它显示的是空白下拉列表-请提供响应您需要为下拉列表指定数据源,否则其中没有项目列表。您可以使用.BindTo()进行此操作 EditorFor()之所以有效,是因为布尔值的内部实现为您创建了True/False项列表 明确定义DropDownList时,需要使用.BindTo()提供值和潜在值列表,即
@{
var boolDataSource=新列表()
{
新建SelectListItem(){Text=“True”,Value=“True”},
新建SelectListItem(){Text=“False”,Value=“False”}
};
//或者,无论您想在何处定义DropDownList使用的项目列表。
}
@Html.Kendo().DropDownListFor(model=>model.Is_Active).BindTo(boolDataSource)
也许吧。工作正常。谢谢:)
@Html.Kendo().DropDownListFor(model => model.Is_Active)
@{
var boolDataSource = new List<SelectListItem>()
{
new SelectListItem() { Text = "True", Value = "True" },
new SelectListItem() { Text = "False", Value = "False" }
};
// Or however/wherever you want to define the list of items that the DropDownList uses.
}
@Html.Kendo().DropDownListFor(model => model.Is_Active).BindTo(boolDataSource)