gpt4 book ai didi

javascript - 如何将此表中的数据作为列表提交到 asp.net mvc 中的操作?

转载 作者:行者123 更新时间:2023-12-03 02:35:59 25 4
gpt4 key购买 nike

 <table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
@*<th style="width:0px"></th>*@
<th>Name</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Price</th>
<th>Company Name</th>
<th style="display:none"></th>

<th></th>
</tr>
</thead>
<tbody>

@foreach (var item in list)
{

<tr>

<td name="pname">@item.Material_Name</td>
<td name="pprice">@item.Quantity</td>
<td name="pdetail">@item.Unit_Price</td>
<td name="pdetail">@item.Total_Price</td>
<td name="pdetail">@item.Name</td>
<td name="pid" style="display:none; white-space:nowrap">item.Id</td>

</tr>
}

</tbody>
</table>
<button class="btn btn-primary btn-lg btn-block" name="save" type="button">Print</button>

我想在操作时从数据表中获取产品列表。获取列表后我想打印该列表。现在我只想获取从数据表到操作的列表。

最佳答案

You need to use BeginForm

Then on click of submit button, you can see your data in to Post Action method.

  @model IList<PaymentSchedule>

@using (Html.BeginForm("SubmitDataToUpload", "Payment", FormMethod.Post, new {enctype = "multipart/form-data"}))
{

<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
@*<th style="width:0px"></th>*@
<th>Name</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Price</th>
<th>Company Name</th>
<th style="display:none"></th>

<th></th>
</tr>
</thead>
<tbody>

/*@foreach (var item in list)*/
/* foreach loop does not generate the correct name attributes */
for(int i = 0; i < Model.Count; i++)
{

<tr>
<td>@Html.TextBoxFor(m =>Model[i].Material_Name)</td>
<td>@Html.TextBoxFor(m =>Model[i].Quantity)</td>
<td>@Html.TextBoxFor(m =>Model[i].Unit_Price)</td>
<td>@Html.TextBoxFor(m =>Model[i].Price)</td>
<td>@Html.TextBoxFor(m =>Model[i].Company)</td>
<td>@Html.TextBoxFor(m =>Model[i].Id)</td>

</tr>
}

</tbody>
</table>



/*Update : Added Submit Button*/

<input class="btn btn-success" type="submit" value="Submit"/>


}


public ActionResult SubmitDataToUpload(List<PaymentSchedule> paymentSchedules)
{
//Add to paymentSchedule
return View("ViewName",paymentSchedules);
}

foreach loop does not generate the correct name attributes for more info :Review This Link

关于javascript - 如何将此表中的数据作为列表提交到 asp.net mvc 中的操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48534783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com