javascript - 如何从存在多个局部视图且每个局部视图没有提交按钮的视图中将值设置为 db?
问题描述
我的视图页面有多个部分视图。每个局部视图都是一个具有唯一输入值的表,每个视图都采用具有不同 id 的相同模型。而且我对所有这些表格都有一个提交按钮。如何检索数据?这是我的部分视图,可以多次渲染。
@{ var i = 1;}
@foreach (var spread in Model.Spreads)
{
var cashSpreadBuy = "cashSpreadBuy" + spread.Curr.ShortName + spread.ID;
var cashBuyCurrent = "cashBuyCurrent" + spread.Curr.ShortName + spread.ID;
var cashSpreadSell = "cashSpreadSell" + spread.Curr.ShortName + spread.ID;
var cashSellCurrent = "cashSellCurrent" + spread.Curr.ShortName + spread.ID;
var nonCashSpreadBuy = "nonCashSpreadBuy" + spread.Curr.ShortName + spread.ID;
var nonCashBuyCurrent = "nonCashBuyCurrent" + spread.Curr.ShortName + spread.ID;
var nonCashSpreadSell = "nonCashSpreadSell" + spread.Curr.ShortName + spread.ID;
var nonCashSellCurrent = "nonCashSellCurrent" + spread.Curr.ShortName + spread.ID;
spread.ID = i;
i++;
<tr>
<td> @spread.Curr.ShortName </td>
<td>
<input asp-for="@spread.CashSpreadBuy" class="form-control" id="@(cashSpreadBuy)" type="number" step="0.01"
onkeyup="Calculate('rateCashBuyCurrent', '@(cashSpreadBuy)', '@(cashBuyCurrent)', false, '@spread.Curr.ShortName')"
onmouseup="Calculate('rateCashBuyCurrent', '@(cashSpreadBuy)', '@(cashBuyCurrent)', false, '@spread.Curr.ShortName')" />
</td>
<td id=@(cashBuyCurrent)> @spread.CashBuyCurrent </td>
<td>
<input asp-for="@spread.CashSpreadSell" class="form-control" id="@(cashSpreadSell)" type="number" step="0.01"
onmouseup="Calculate('rateCashSellCurrent', '@(cashSpreadSell)', '@(cashSellCurrent)', false, '@spread.Curr.ShortName')"
onkeyup="Calculate('rateCashSellCurrent', '@(cashSpreadSell)', '@(cashSellCurrent)', false, '@spread.Curr.ShortName')" />
</td>
<td id=@(cashSellCurrent)> @spread.CashSellCurrent </td>
<td>
<input asp-for="@spread.NonCashSpreadBuy" class="form-control" id="@(nonCashSpreadBuy)" type="number" step="0.01"
onmouseup="Calculate('rateNonCashBuyCurrent', '@(nonCashSpreadBuy)', '@(nonCashBuyCurrent)', false, '@spread.Curr.ShortName')"
onkeyup="Calculate('rateNonCashBuyCurrent', '@(nonCashSpreadBuy)', '@(nonCashBuyCurrent)', false, '@spread.Curr.ShortName')" />
</td>
<td id=@(nonCashBuyCurrent)> @spread.NonCashBuyCurrent </td>
<td>
<input asp-for="@spread.NonCashSpreadSell" class="form-control" id="@(nonCashSpreadSell)" type="number" step="0.01"
onmouseup="Calculate('rateNonCashSellCurrent', '@(nonCashSpreadSell)', '@(nonCashSellCurrent)', false, '@spread.Curr.ShortName')"
onkeyup="Calculate('rateNonCashSellCurrent', '@(nonCashSpreadSell)', '@(nonCashSellCurrent)', false, '@spread.Curr.ShortName')" />
</td>
<td id=@(nonCashSellCurrent)> @spread.NonCashSellCurrent </td>
</tr>
}
</tbody>
</table>
这是我的视图的块方案: 在此处输入图像描述
解决方案
推荐阅读
- firebase - BigQuery - 如何按事件排序
- html - 如何从重复选择框保存的数组中获取每个数据
- node.js - 当我在 node.js 中运行 socket.io 和在 react.js 中运行 socket.io-client 时,无限循环
- amazon-web-services - cloudwatch event in aws lambda function not work in my aws educate account
- google-drive-api - 无论如何,是否可以使用 Google Drive API 列出哪些文件可以与任何有链接的人共享或可以公开搜索?
- php - 使用 Apache 和 Kohana 创建 PHP 服务器
- sas - 使用数据步骤中的 put 语句写入 SAS EG 中的默认 HTML 输出
- reactjs - 将选定的值保留在 React 的一组单选按钮中
- html - 由于全宽行,引导 4 网格空白
- javascript - Sequelize 模型关联不会创建新列