public ActionResult Create()
{
try
{
var Group = GroupRepository.FindAllGroups();
ViewData["Group"] = GroupRepository.FindAllGroups();
ViewData["Feature"] = FeatureRepository.FindAllFeatures();
DataTable dt = FeatureRepository.GetAllFeatures();
// TODO: Add insert logic here
Group group = new Group()
{
dtm_CreatedDate = DateTime.Now,
int_CreatedBy = 1
};
return View(group);
}
catch
{
return View();
}
}
我想将数据表以及组对象发送到视图。我将如何做到
答案 0 :(得分:4)
创建新的特定类,它将Group对象保留为成员以及您需要在View
中使用的任何对象public class MySpecificViewClass
{
public Group Group;
...
}
之后将此类实例指定为View参数
return View(new MySpecificViewClass { Group = group, ... } );