【发布时间】:2021-08-24 15:12:51
【问题描述】:
我在一行中有一些小数列,它们分组在 emphrs 类下。但是当我在表中添加新行时,如何将 0.00 设置为 emphrs 类下分组的所有列的默认值
在我的模型类 EmpHrs.cs 中的列属性
public decimal SundayNetHrs { get; set; }
public decimal MondayNetHrs { get; set; }
public decimal TuesdayNetHrs { get; set; }
public decimal WednesdayNetHrs { get; set; }
public decimal ThursdayNetHrs { get; set; }
public decimal FridayNetHrs { get; set; }
public decimal SaturdayNetHrs { get; set; }
在 EmpHrs Html 我有一个带有 EmpHrs 列的表
<tbody>
<tr>
<td>@Html.TextBoxFor(model => model.FromDate, new { @class = "form-control date-input" })</td>
<td>@Html.TextBoxFor(model => model.ToDate, new { @class = "form-control date-input" })</td>
<td>@Html.EditorFor(model => model.SundayNetHrs, new { htmlAttributes = new { type = "number", @class = "form-control w-100 empHrs" } })</td>
<td>@Html.EditorFor(model => model.MondayNetHrs, new { htmlAttributes = new { type = "number", @class = "form-control w-100 empHrs" } })</td>
<td>@Html.EditorFor(model => model.TuesdayNetHrs, new { htmlAttributes = new { type = "number", @class = "form-control w-100 empHrs" } })</td>
<td>@Html.EditorFor(model => model.WednesdayNetHrs, new { htmlAttributes = new { type = "number", @class = "form-control w-100 empHrs" } })</td>
</tr>
</tbody>
<button type="button" id="btnUpdate" name="submitButton" value="DeleteAtt"
class="btn btn-primary form-control" onclick="AddNew();">
<i class="fa fa-save"></i><span class="padding-left-ten">Add New Row</span>
</button>
function AddNew() {
var clone = $("#tblEntry tr:last").clone().find('input').val('').end().insertAfter("#tblEntry tr:last");
$(clone).find(".date-input").datepicker({ format: 'dd/mm/yyyy', todayHighlight: true, date: new Date(), autoclose: true, todayBtn: 'linked' });
// Here All column under EmpHrs class should be set default value 0.00
}
【问题讨论】:
标签: html asp.net-core