1

我需要将在“AuctionPage”上选择的线圈发送到“MyBids”页面上的另一个表。我认为最好抓住线圈ID并以这种方式传递但不知道如何?任何帮助,将不胜感激。

拍卖页面-->

@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">&times;</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>

我的投标页面-->

@model NucorPrototypes_V1.ViewModel.MyBids

@{

ViewBag.Title = "MyBids";

}

拍卖

二次线圈拍卖每 100 重量的投标金额 删除投标序列号 最小投标电流 高投标等级 热号 仪表宽度 重量 缺陷 1 缺陷 2 缺陷 3 @foreach( var row in Model.Coils) { Remove Bid @Html.DisplayFor( modelItem => row.Coil_ID) }
<center>

确认投标

另存为...

</center>

4

2 回答 2

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);
}
于 2013-11-14T20:47:39.747 回答
0

只需将复选框放在一个子表单中,该操作将转到目标表单。我看不到该语句在您提供的 HTML 中的位置,但是您可以在同一页面上有多个具有不同目标的表单。

于 2013-11-14T15:45:14.237 回答