我添加了 @model IEnumerable 而不是 @model TravelSOCC.Models.LansingMileage,这将不再允许我访问我的 ExpMonthYr
我知道根据文档,这两个函数应该分开,因为它们正在执行不同的任务,只是试图让最终用户有更少的页面来导航。
这样做的目的是允许用户从日期选择器中选择一个日期,然后更新数据库并使用它重新显示在表中,这意味着我需要@foreach能够@Html.EditorFor在@Foreach相同的视图但不在同一个表中。
@model IEnumerable<TravelSOCC.Models.LansingMileage>
<h3>STATE OFFICERS COMPENSATION COMMISSION (SOCC)</h3>
@using (Html.BeginForm())
{
<table class="table">
<tr>
<th>Senator Information</th>
<th>Monthly Expense Summary</th>
<th>Expense Month/Year</th>
</tr>
<tr>
<td>State Senator</td>
<td>Mileage Total:<br />Expense Total:<br /><strong>Total:</strong></td>
<!--This will become a datepicker-->
<td>@Html.EditorFor(model => model.ExpMonthYr, new { htmlAttributes = new { @class = "datepicker", Name = "expenseDate" } })</td>
</tr>
</table>
}
<table id="LansingData" class="display">
<thead>
<tr>
<th>Expense Month/Yr</th>
<th>Travel Date</th>
<th>Travel Type</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr id="">
<!--Here is where I will create a table to display my data from the above section-->
</tr>
}
</tbody>
</table>
www说
眼眸繁星
相关分类