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, ... } );
精彩评论