user2989650
user2989650

Reputation: 13

This table has a column with check boxs that need to select the row and send rows to another table.

I need to send the coils selected on "AuctionPage" to the another table on "MyBids" Page. I think it would be best to grab the coilID and pass it that way but not sure how? Any help would be appreciated.

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">&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>

Place Bid(s)

</center>

MyBids Page-->

@model NucorPrototypes_V1.ViewModel.MyBids

@{

ViewBag.Title = "MyBids";

}

Auction

Secondary Coil Auction Bid Amount per 100 weight Remove Bid Serial Number Minimum Bid Current High Bid Grade Heat Number Gauge Width Weight Defect 1 Defect 2 Defect 3 @foreach( var row in Model.Coils) { Remove Bid @Html.DisplayFor( modelItem => row.Coil_ID) }
<center>

Confirm Bids

Save as...

</center>

Upvotes: 1

Views: 120

Answers (2)

Matt Bodily
Matt Bodily

Reputation: 6413

for getting the result of multiple check boxes I use Request.Form on your controller

Request.Form["chkBoxName"].ToString();

make sure every check box has the same name (chxBoxName in this example) and it will give you a list of all of the check boxes that were selected. You can then add those items to the next table on the controller and redirect there. Hope this helps

Edit:

this will return a comma delimited list of the selected check boxes. since you want to add them to another table you will need to query the database for them.

[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);
}

Upvotes: 1

Danny Nicholas
Danny Nicholas

Reputation: 1

Just put the checkboxes in a sub form where the action goes to the target form. I don't see where the statement is in the HTML you provided, but you can have multiple forms on the same page with differing targets.

Upvotes: 0

Related Questions