C# DevExpress ASP.NET MVC组合框不显示值
在我的PartialView中,我添加了一个带有列的网格,我需要以这种方式将其作为组合框C# DevExpress ASP.NET MVC组合框不显示值,c#,asp.net-mvc,razor,combobox,devexpress-mvc,C#,Asp.net Mvc,Razor,Combobox,Devexpress Mvc,在我的PartialView中,我添加了一个带有列的网格,我需要以这种方式将其作为组合框 settings.Columns.Add(column => { column.FieldName = "TheFieldName"; column.Caption = "ACaption"; column.ColumnType = MVCxGridViewColumnType.ComboBox; var comboBoxPro
settings.Columns.Add(column =>
{
column.FieldName = "TheFieldName";
column.Caption = "ACaption";
column.ColumnType = MVCxGridViewColumnType.ComboBox;
var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.DataSource = ViewData["MyListOfObjects"];
comboBoxProperties.TextField = "Description";
comboBoxProperties.ValueField = "Description";
comboBoxProperties.ValueType = typeof(String);
});
ViewData是在控制器的Index方法中填充的,我已经检查过它是否填充了包含值的对象
**编辑**
控制器代码:
公共异步任务索引()
{
if(TempDataId==null)
返回重定向到动作永久(“索引”,“其他控制器”)
//如果使用Visual Studio进行调试,将填充ViewData[“MyListOfObjects”]
ViewData[“MyListOfObjects”]=await Worker.GetAllListOfObjects();
MyViewModel MyViewModel=新的MyViewModel
{
MyListOne=await Worker.GetAllListOfObjectsWithId(TempDataId),
MyListTwo=新列表()
};
返回视图(tipomaViewViewModel);
}
数据访问实体框架代码优先方法GetAllListoObjects:
public async Task<List<SimpleObjectEntity>> GetAllListOfObjects()
{
try
{
return await DataContext.SimpleObjectEntities.ToListAsync();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
return null;
}
public异步任务GetAllListOfObjects()
{
尝试
{
返回wait wait DataContext.SimpleObjectEntities.toListSync();
}
捕获(例外情况除外)
{
Debug.WriteLine(ex);
}
返回null;
}
包含部分网格视图的索引视图
@model Models.ViewViewModel.MyViewViewModel
@using Internationalization
@{
Html.EnableClientValidation();
ViewBag.Title = Resources.MenuLeftBar;
}
<h4>@Resources.Menu- @Resources.MenuLeftBar</h4>
<div>@Html.Partial("AGridViewPartial", Model.MyListOne)</div>
<br/>
<div>@Html.Partial("AnotherWithComboboxColumnGridViewPartial", Model.MyListTwo)</div>
@model Models.viewmodel.myviewmodel
@使用国际化
@{
Html.EnableClientValidation();
ViewBag.Title=Resources.MenuLeftBar;
}
@Resources.Menu-@Resources.MenuLeftBar
@Html.Partial(“AGridViewPartial”,Model.MyListOne)
@Html.Partial(“AnotherWithComboboxColumnGridViewPartial”,Model.MyListTwo)
PopupEditForm中的组合框不显示任何内容
你知道会出什么问题吗
关于。描述是公共get/set属性吗?是的,实体框架代码首先将数据源POCOIs为
IEnumerable
?填充ViewData的代码是什么样子的?还有,你的标题代码有误。嗨,用所有需要的代码更新了我的问题,留下了实体实现,它是实体框架和域通常使用的普通POCO类。
@model Models.ViewViewModel.MyViewViewModel
@using Internationalization
@{
Html.EnableClientValidation();
ViewBag.Title = Resources.MenuLeftBar;
}
<h4>@Resources.Menu- @Resources.MenuLeftBar</h4>
<div>@Html.Partial("AGridViewPartial", Model.MyListOne)</div>
<br/>
<div>@Html.Partial("AnotherWithComboboxColumnGridViewPartial", Model.MyListTwo)</div>