View
@if (weekMaster != null)
{
using (Html.BeginForm("UpdatePlan", "generalPlan", FormMethod.Post, new { }))
{
<table class="table-bordered">
<tr>
@foreach (TermMaster obj in weekMaster.ToList())
{
<td align="center">
<span> @obj.termStartDate.ToString("dd MMM") - @obj.termEndDate.ToString("dd MMM")</span>
<br />
<input type="hidden" name="ObjHid" value="@obj" />
<input type="hidden" name="startDate" value="@obj.termStartDate" />
<input type="hidden" name="endDate" value="@obj.termEndDate" />
<input type="text" style="width:80%" name="weekSession" />
</td>
}
<td>
<input type="submit" value="Update" class="btn-primary" />
</td>
</tr>
</table>
} }
Controller
[HttpPost]
public ActionResult UpdatePlan(List<DateTime> startDate, List<DateTime> endDate, List<int> weekSession, List<TermMaster> ObjHid)
{
return View();
}
I am trying pass Class Object from View to Controller
above TermMaster class Object pass using input method <input type="hidden" name="ObjHid" value="@obj" />
but showing NULL
value if pass single value like startDate
and endDate
then it work fine.
What is wrong in my code? how to pass class object List in Post Method?