我有一个带有组合框的部分 View 。当尝试使用模态渲染部分 View (包含数据库中的数据)时,它仅显示值字段。我想显示该值字段的文本字段。请帮助我。
@(Html.Kendo().ComboBoxFor(m => m.divCode)
.DataTextField("Name")
.DataValueField("ID")
.HtmlAttributes(new { style = "width:160px" })
.SelectedIndex(0)
.AutoBind(false)
.Placeholder("Select Div Code")
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetDivision", "AssetTransaction");
});
})
)
最佳答案
我发现您的查看代码没有错误。它对我来说看起来不错。我认为你正在做同样的事情 this sample .
我怀疑您对 c.divisioncode, Name = c.divisionname
的赋值。只需确保您正在获取并设置 value and text
正确地从您的数据库服务调用中查看模型并正确分配。为此,您可以使用并查看“快速观看”while debugging the GetDivision "Action" in AssetTransaction "controller"
.
我找到的示例代码:
@(Html.Kendo().ComboBox()
.Name("products")
.DataTextField("ProductName")
.DataValueField("ProductID")
.HtmlAttributes(new { style = "width:250px" })
.Filter("contains")
.AutoBind(false)
.MinLength(3)
.DataSource(source => {
source.Read(read =>
{
read.Action("GetProducts", "Home");
})
.ServerFiltering(true);
})
)
关于c# - Kendo 组合框不显示与模式中的值相对应的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31041329/