我的视图中有一个HTML表格如下:
<table id="tblCurrentYear">
<tr>
<td>Leave Type</td>
<td>Leave Taken</td>
<td>Leave Balance</td>
<td>Leave Total</td>
</tr>
@foreach (var item in Model.LeaveDetailsList)
{
<tr>
<td>@Html.TextBoxFor(m => item.LeaveType, new { width = "100" })</td>
<td>@Html.TextBoxFor(m => item.LeaveTaken, new { width = "100" })</td>
<td>@Html.TextBoxFor(m => item.LeaveBalance, new { width = "100" })</td>
<td>@Html.TextBoxFor(m => item.LeaveTotal, new { width = "100" })</td>
</tr>
}
</table>
Run Code Online (Sandbox Code Playgroud)
我想遍历所有html表行并在ADO.NET DataTable中插入值.
简单来说,将HTML表转换为ADO.NET DataTable.
如何从HTML表中提取值并插入到ADO.NET DataTable中?
该视图基于以下模型
public class LeaveBalanceViewModel
{
public LeaveBalanceViewModel()
{
this.EmployeeDetail = new EmployeeDetails();
this.LeaveBalanceDetail = new …Run Code Online (Sandbox Code Playgroud) 我有这样的表格:https://gyazo.com/289a1ac6b7ecd212fe79eec7c0634574
JS代码:
$(document).ready(function() {
$("#add-more").click(function() {
selectedColor = $("#select-color option:selected").val();
if (selectedColor == '')
return;
var color = ' <
div class = "form-group" >
<
label class = "col-md-2 control-label" > Color: < /label> <
div class = "col-md-5" > < label class = "control-label" > ' + selectedColor + ' < /label></div >
<
/div>
';
var sizeAndQuantity = ' <
div class = "form-group" >
<
label class = "col-md-2 control-label" > Size and …Run Code Online (Sandbox Code Playgroud) 我通过表单HttpPost将ViewModel从我的View传递回Controller.但是,返回的值始终为NULL.
视图模型
public class vmCompanyAddress
{
public StatelyTechAdmin.Models.Company Company { get; set; }
public StatelyTechAdmin.Models.CompanyAddress Address { get; set; }
public SelectList Counties { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
公司类模型
public class Company
{
[Key]
public virtual long CompanyId { get; set; }
[Required]
[Display(Name = "Company Name")]
public virtual string Name { get; set; }
public virtual DateTime CreatedDate { get; set; }
public virtual IEnumerable<CompanyAddress> CompanyAddresses { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
CompanyAddress类模型
public class CompanyAddress
{
[Key]
public virtual …Run Code Online (Sandbox Code Playgroud)