New to mvc, I have a controller like this
public ActionResult Index(DateTime Date, DateTime DDate)
{
DateTime dt = System.DateTime.Now.AddDays(5);
ViewBag.b = dt;
return View();
}
[HttpPost]
public ActionResult Index(DateTime Date, DateTime DDate)
{
List<myCollection> myCollectionList = new List<myCollection>();
// Fill the list
return View();
}
Now, what I want to do is pass the myCollectionList to view (Razor cshtml) for displaying the collection records
Edited: myCollection class is in controller
public class myCollection
{
public string date { get; set; }
public string ddate { get; set; }
}
I’m not sure I understand correctly. You can simply return the myCollectionList from the action:
The access it from the View using the Model property:
See also this blog post.