![](/img/trans.png)
[英]Get value from a table cell and display in partial view table cell in MVC
[英]how to display datetime arraylist in textboxfor in table Partial view mvc
我有 arraylist 包含 id,datetime 和 boolen(Chechbox),當它僅在表中綁定時 datetime 不會以寫入方式綁定,如果它在 textboxfor 中綁定(我需要使日期可編輯)它在標簽中綁定正確
<tbody id="employeeScheduleList">
@if (Model != null && Model.R != null && Model.R.Count() > 0)
{
foreach (var file in Model.R)
{
<tr>
<td>
<div class="form-group">
@if (@file.ReceivingDateValue != null)
{
@file.ReceivingDateValue.Value.ToShortDateString()
}
@Html.TextBoxFor(m => file.ReceivingDateValue, new { @class = "form-control ReceivingDate ", type = "Date", id = "ReceivingDate_" })
@if (file.ReceivingDateValue != null)
{
<script>
var t = document.getElementById("ReceivingDate_");
t.value = '@file.ReceivingDateValue.Value.ToString("yyyy-MM-dd")';
</script>
}
@Html.ValidationMessageFor(model => file.ReceivingDateValue, "", new { @class = "text-danger" })
</div>
</td>
</tr>
}
}
</tbody>
我在@Html.TextBoxFor(m => file.ReceivingDateValue, new { @class = "form-control ReceivingDate ", type = "Date", id = "ReceivingDate_" })
中的問題,因為 ReceivingDateValue 的值綁定正確當我在 chrome 中檢查它時,我找到了寫入值,但它的文本框顯示錯誤的值我想在文本框中查看日期以使其可編輯
lambda 表達式x=> file.FileIDValue
將值從客戶端綁定到 controller。 將值作為屬性添加應該從服務器綁定到客戶端並提供您正在尋找的結果
@Html.TextBoxFor(x => file.FileIDValue, new { @class = "form-control hidden EMPF", value = File.FileIDValue }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.