tags:

views:

31

answers:

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

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

+4  A: 

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, ... } );
zerkms
+1, you beat me to it, just expose the datatable as a property of MySpecificClass
Mark Dickinson
Not really, I wouldn't do it that way. Rather copy it to something more generic like a List or IEnumerable. DataTable feels so ADO.NET and WebForms, just my 2 cents..
mare
Ok thanks I got your point collections could be much better
mazhar kaunain baig