我尝试在May main视图中渲染局部视图时遇到问题

问题描述 投票:0回答:1

我有以下局部视图:

@model IDECOHealthInsurance.Models.Pharmacy
@using (Ajax.BeginForm("pharmacyDetials", "Pharmacy", new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "pDetail", InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, LoadingElementId = "Loading", OnBegin = "" }))
{


<h4>تفاصيل الصيدلية</h4>

<div id="pDetail" class="MainGridContainer pb-5">

    @if (Model.dtItemsDetails != null)
    {

        <table dir="rtl" id="Paitents" class="MainGrid">
            <thead>
                <tr style="text-size-adjust:auto">

                    <th>
                        رقم الموظف
                    </th>
                    <th>
                        التاريخ
                    </th>
                    <th>
                        الوقت
                    </th>
                    <th>
                        المستفيدون
                    </th>
                    <th>
                        ملاحظات
                    </th>
                    <th>
                        الباركورد
                    </th>
                    <th>
                        أسم العينة
                    </th>
                    <th>
                        الكمية
                    </th>
                    <th>
                        السعر
                    </th>

                </tr>
            </thead>
            <tbody>

                @foreach (System.Data.DataRow row in Model.dtItemsDetails.Rows)
                {
                    <tr style="width:100%">

                        <td>
                            @row["EMPLOYEE_NUMBER"]
                        </td>
                        <td>
                            @row["ENTRY_DATE"]
                        </td>
                        <td>
                            @row["ENTRY_TIME"]
                        </td>
                        <td>
                            @row["BENEFICIARIES"]
                        </td>
                        <td>
                            @row["NOTE"]
                        </td>

                        <td>
                            @row["ITEM_CODE"]
                        </td>
                        <td>
                            @row["ITEM_NAME"]
                        </td>
                        <td>
                            @row["QTY"]
                        </td>
                        <td>
                            @row["PRICE"]
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    }
</div>
}

和下面的控制器:

[HttpGet]

        public ActionResult pharmacyDetials(Pharmacy model)
        {
            var masterID = Convert.ToInt32(Session["login"]);
            if (masterID == 0)
            {
                return RedirectToAction("Login");
            }
            else
            {
                Models.Pharmacy objPharamcyMode = new Pharmacy();

                IDECOServiceReference.IdecoAPIServiceClient idecoAPI = new IDECOServiceReference.IdecoAPIServiceClient();
                DataTable dataTable = idecoAPI.GETPHARMACYEMPLOYEEMASTER("", 1);

                model.dtItemsDetails = dataTable;

                return PartialView("_PharmacyDetails", model);
            }
        }

以及以下主视图:

@model IDECOHealthInsurance.Models.Pharmacy

@{
    ViewBag.Title = "PharmacyApplication";
    Layout = "~/Views/Shared/_Layout.cshtml";

}

<table style="height:680px; width:1280px; border:hidden">
    <tr>
        <td>
            <div id="pDetail">          
                    @Html.Partial("_PharmacyDetails", Model)

                </div>
        </td>
        <td>

            @using (Ajax.BeginForm("PharmacyApplication", "Pharmacy", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "updatePnl", InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, LoadingElementId = "Loading", OnBegin = "" }))
            {


                    <div class="form-horizontal">
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-10">
                            <input type="submit" id="panel" value="أضافة" class="btn btn-default" />
                        </div>

                        <input class="btn btn-default" type="button" value="خروج" onclick="@("window.location.href='" + @Url.Action("LogOut", "Pharmacy") + "'");" />
                    </div>

                </div>

            }
        </td>
    </tr>
</table>

<div id="updatePnl">
    @Html.Partial("_PartialPharmacyDetails", Model)
</div>
<br />
<br />
<br />

<div id="pnlItemsDetails">
    @Html.Partial("_PartialItemsDetails", Model)
</div>

[当我尝试在主视图中呈现_PharmacyDetails时,它不会返回任何记录。问题是什么?以及我该如何解决?请向我提供有关此问题如何发生的解释。我做错了什么?

asp.net-mvc model-view-controller asp.net-mvc-5
1个回答
0
投票

而不是使用Partial方法渲染局部视图,我使用了Action方法:

© www.soinside.com 2019 - 2024. All rights reserved.