我需要将“AuctionPage”上选择的线圈发送到“MyBids”页面上的另一个表格。我认为最好抓住coilID并以这种方式传递但不确定如何?任何帮助将不胜感激。
AuctionPage - >
@model NucorPrototypes_V1.ViewModel.AuctionPage
@ {
ViewBag.Title = "Index";
}
<title>Auction </title>
<div id="header" style="background-color: #008751">
<h1 style="margin-bottom: 0; color: #FFFFFF">Secondary Coil Auction </h1>
</div>
<div id="content">
<h2>Index</h2>
<table id="myTable" border="3" style="background-color: #B0B0B0" cellpadding="10" class="table">
<tr>
<th>Select</th>
<th>Serial Number</th>
<th>Minimum Bid</th>
<th>Current High Bid</th>
<th>Grade</th>
<th>Heat Number</th>
<th>Gauge</th>
<th>Width</th>
<th>Weight</th>
<th>Defect 1</th>
<th>Defect 2</th>
<th>Defect 3</th>
</tr>
@foreach (var item1 in Model.Coils)
{
<tr>
<td>
<input type="checkbox" name="selection" id="@item1.Coil_ID" align="center">
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_ID)
</td>
<td>
@foreach (var item2 in Model.Auctions)
{
@Html.DisplayFor(modelItem => item2.Auc_MinBid)
}
</td>
<td>
@foreach (var item3 in Model.Bids)
{
@Html.DisplayFor(modelItem => item3.Bid_Amt)
//string sqlq = "select max(Bid_Amt) from Bid inner join AuctionItem ON Bid.Bid_ID = AuctionItem.Bid_ID where Coil_ID =" + item1.Coil_ID +"' '";
}
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Grade)
</td>
<td>
<a data-toggle="modal" data-target="#myModal">@Html.DisplayFor(modelItem => item1.Coil_HeatNo)</a>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">@Html.DisplayFor(modelItem => item1.Coil_HeatNo)</h4>
</div>
<div class="modal-body">
CHemistries
</div>
</div>
</div>
</div>
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Gauge)
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Width)
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Weight)
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Defect1)
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Defect2)
</td>
<td>
@Html.DisplayFor(modelItem => item1.Coil_Defect3)
</td>
</tr>
}
</table>
</center>
</div>
<center>
</center>
MyBids页面 - &gt;
@model NucorPrototypes_V1.ViewModel.MyBids
@ {
ViewBag.Title = "MyBids";
}
拍卖
二次线圈拍卖 每100重量的投标金额 删除出价 序列号 最低出价 目前的高出价 年级 热数 规 宽度 重量 缺陷1 缺陷2 缺陷3 @foreach(Model.Coils中的var行) { 删除出价 @ Html.DisplayFor(modelItem =&gt; row.Coil_ID) }
<center>
确认出价
另存为...
</center>
答案 0 :(得分:1)
获取多个复选框的结果我使用Request.Form 在你的控制器上
Request.Form["chkBoxName"].ToString();
确保每个复选框具有相同的名称(在此示例中为chxBoxName),它将为您提供所选的所有复选框的列表。然后,您可以将这些项添加到控制器上的下一个表中并重定向到那里。希望这有帮助
编辑:
这将返回所选复选框的逗号分隔列表。因为你想将它们添加到另一个表中,你需要为它们查询数据库。
[HttpPost]
public ActionResult PostBack(){
Model model = new Model();
List<Bids> bids = new List<Bids>();
List<int> result = Request.Form["chkBoxName"].ToString().split(',');
foreach(var id in result){
//query the database to get the record for id
bids.add("result of query");
}
Model.Bids = bids;
return RedirectToAction("Bids", bids);
}
答案 1 :(得分:0)
只需将复选框放在子表单中,即操作转到目标表单。我没有看到您提供的HTML中的语句位置,但您可以在同一页面上使用不同目标的多个表单。