【发布时间】:2020-06-01 13:41:06
【问题描述】:
我正在尝试通过控制器中的存储过程将模型传回控制器以进行大规模更新。需要传回控制器的两个关键值是视图中选定的下拉列表和日历日期。模型中有用于存储信息的字段,但我不知道如何填充模型中的值。
这是当前代码:
<div>
<a href="#" id="addNew">Add New</a>
</div>
<p>
PlantArea: @Html.DropDownList("PlantArea", " ")
EntryDate: @Html.TextBox("EntryDate", @DateTime.Now.ToShortDateString(), new { id = "Calendar", @class = "datepicker" })
<input type="submit" value="Load Daily Entries" />
<br /> <br />
</p>
<table id="dataTable" border="0" cellpadding="0" cellspacing="0">
<tr>
<th>Employee Id</th>
<th>Employee Name</th>
<th>Status Reason</th>
<th>HR Comment</th>
</tr>
@if (Model != null && Model.Count > 0)
{
int j = 0;
foreach (var i in Model)
{
<tr style="border:1px solid black">
<td>@Html.TextBoxFor(a => a[j].EmployeeId)</td>
<td>@Html.TextBoxFor(a => a[j].Preferred_Name)</td>
<td>@Html.TextBoxFor(a => a[j].Entry_Code, new { @Value = ViewBag.DefaultAttendanceCode })</td>
<td>@Html.TextBoxFor(a => a[j].HR_Comment)</td>
<td>>@Html.TextBoxFor(a => a[j].EntryDate, new { @Value = EntryDate})</td>
<td>>@Html.TextBoxFor(a => a[j].Entry_Code, new { @Value = PlantArea })</td>
<td>
@if (j > 0)
{
<a href="#" class="remove">Remove</a>
}
</td>
</tr>
【问题讨论】:
标签: c# asp.net-mvc view insert