asp.net mvc发送值来查看

时间:2010-05-10 08:33:14

标签: asp.net-mvc

        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();
            }
        } 

我想将数据表以及组对象发送到视图。我将如何做到

1 个答案:

答案 0 :(得分:4)

创建新的特定类,它将Group对象保留为成员以及您需要在View

中使用的任何对象
public class MySpecificViewClass
{
    public Group Group;
    ...
}

之后将此类实例指定为View参数

return View(new MySpecificViewClass { Group = group, ... } );