开发者

asp.net mvc sending values to view

        public ActionResult Create()
        {
            try
            {
                var Group = GroupRepository.FindAllGroups();
                ViewData["Group"] = GroupRepository.FindAllGroups();
                ViewData["Feature"] = FeatureRepository.FindAllFeatures();
                DataTable dt = FeatureRepository.GetAllFeatures();

 开发者_C百科               // TODO: Add insert logic here
                Group group = new Group()
                {
                    dtm_CreatedDate = DateTime.Now,
                    int_CreatedBy = 1

                };
               return View(group);

            }
            catch
            {
                return View();
            }
        } 

I want to send the datatable as well as the group object to the view. how will i do that


Create new specific class, that will keep the Group object as member and any objects you need to use in View

public class MySpecificViewClass
{
    public Group Group;
    ...
}

and after this specify this class instance as View argument

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜