Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, at the moment I have a OrderConfirmationController which has a Details view which displays the records. At the bottom of the Details View I want to add 5 fields from another table that will be displayed in the view but not sure how to add them.

At the bottom of the last table I want to implement a separate table containing the Product_ID, Description, Price, Quantity and Total from a Sales_Order_Line table but don't know how to add it as I can only reference one table using the @model at the start of the view.

Thanks.

Here is my code for the Details controller:
C#
   public ActionResult Details(string documentNo, int documentType)
{
    // Compound key is used here so require both fields to be included in the SQL.
    Sales_Order confirmOrder = _data.Sales_Orders
       .Where(x => x.Document_Type == documentType && x.Document_No_ == documentNo)
       .FirstOrDefault();
    return View(confirmOrder);


}


Here is the code for my view:
@model SPR.Titanium.MultiChannel.ManagementConsolePortal.Sales_Order


<link href="~/Content/themes/ui-lightness/jquery-ui-1.10.3.custom.css" rel="stylesheet"     />

@section Scripts
{
@Scripts.Render("~/bundles/jqueryui");
<script src="~/js/jquery-1.9.1.js"></script>
<script src="~/js/jquery-ui-1.10.3.custom.js"></script>
<script>
    $(function () {
        $("#accordion").accordion();
    })
</script>

}

@{
ViewBag.Title = "Order Confirmation Details";
}

<h2>Order Confirmation</h2>

@using (Html.BeginForm())
{
<div id="accordion">
    <div class="editor-field">
        Billing Details:
    </div>
    <div class="editor-field">
        <table style="width:100%">
            <tr>
                <th style="width:20%">Billing Name</th>
                <td style="width:30%">@Html.EditorFor(model =>   model.Sell_to_Customer_Name)</td>
                <th style="width:20%">Address</th>
                <td style="width:30%">@Html.EditorFor(model => model.Bill_to_Address).  </td>
                <th style="width:20%">Address 2</th>
                <td style="width:30%">@Html.EditorFor(model => model.Bill_to_Address).  </td>
            </tr>
            <tr>
                <th style="width:20%">City</th>
                <td style="width:30%">@Html.EditorFor(model => model.Bill_to_City)</td>
                <th style="width:20%">County</th>
                <td style="width:30%">@Html.EditorFor(model => model.Bill_to_County).</td>
                <th style="width:20%">Post Code</th>
                <td style="width:30%">@Html.EditorFor(model => model.Bill_to_Post_Code)</td>
            </tr>
            <tr>
                <th style="width:20%">Country</th>
                <td style="width:30%">@Html.EditorFor(model => model.Bill_to_Country_Region_Code)</td>
            </tr>

        </table>
    </div>
    <div class="editor-label">
        Delivery Details
    </div>
    <div class="editor-field" aria-readonly="true">
        <table style="width:100%">
            <tr>
                <th style="width:20%">Delivery Name</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_Contact_Name)</td>
                <th style="width:20%">Address</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_Address)</td>
                <th style="width:20%">Address 2</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_Address_2)</td>
                </tr>
            <tr>
                <th style="width:20%">City</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_City)</td>
                <th style="width:20%">County</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_County)</td>
                <th style="width:20%">Post Code</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_Post_Code)</td>
            </tr>
            <tr>
                <th style="width:20%">Country</th>
                <td style="width:30%">@Html.EditorFor(model => model.Ship_to_Country_Region_Code)</td>
            </tr>
            </table>
    </div>

</div>    
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900