2013-04-27 37 views
1

我在我的主cshtml中有一個網格作爲partialview。當我單擊網格中的頁碼時,網格正在消失。任何建議?Webgrid消失,同時單擊MVC3中的分頁

Devices.csthml(partialview)

即使我已經div的我的網格中局部視圖。

<div id="my-grid"> 
    @{ 

     var grid = new WebGrid(
           canPage: true, 
           canSort: true, 
          rowsPerPage: 3, 
          ajaxUpdateContainerId: "my-grid"); 

      grid.Bind(Model, rowCount: Model.Count(), autoSortAndPage: true); 



     @grid.GetHtml(
     htmlAttributes: new { id = "my-grid" }, 
     tableStyle: "grid1", 
     headerStyle: "header", 
     rowStyle: "row", 
     footerStyle: "footer", 
     alternatingRowStyle: "altRow", 
     columns: grid.Columns(
           grid.Column("ObjectOfServiceName", "Device Name", style: "textCol"), 
           grid.Column("SerialNumber", "Serial Number", style: "textCol"), 
           grid.Column("ContractIdentifier", "Contract Identifier", style: "textCol"), 
           grid.Column("ServiceLevelCode", "Service Level", style: "textCol"), 
           grid.Column("UserDeviceDescription", "Device Grouping", style: "textCol"), 
           grid.Column(header: "", format: @<text>@Html.ActionLink("Upgrade", "DeviceUpgradePartial", new { objectOfServiceId = item.ObjectOfServiceId, serviceContractId = item.ServiceContractId, serialNumber = item.SerialNumber, objectOfServiceName = item.ObjectOfServiceName, serviceLevelId = item.ServiceLevelId, deviceGroupingId = item.DeviceGroupingId }, new { @class = "upgradeLink", title = "Upgrade Device" })" </text>, style: "colOperation"), 
           grid.Column(header: "", format: @<text>@Html.ActionLink("Update", "DeviceUpdatePartial", new { objectOfServiceId = item.ObjectOfServiceId, serviceContractId = item.ServiceContractId, serialNumber = item.SerialNumber, objectOfServiceName = item.ObjectOfServiceName, serviceLevelId = item.ServiceLevelId, deviceGroupingId = item.DeviceGroupingId }, new { @class = "updateLink", title = "Update Device" })" </text>, style: "colOperation"), 
           grid.Column(header: "", format: @<text>@Html.ActionLink("ReassignDeviceGroup", "ReassingDeviceGroupingPartial", new { objectOfServiceId = item.ObjectOfServiceId, serviceContractId = item.ServiceContractId, serialNumber = item.SerialNumber, objectOfServiceName = item.ObjectOfServiceName, serviceLevelId = item.ServiceLevelId, deviceGroupingId = item.DeviceGroupingId }, new { @class = "reassingDeviceGroupLink", title = "Update Device" })" </text>, style: "colOperation") 

          ), mode: WebGridPagerModes.All) 




    } 
</div> 

Main.cshtml:

<tr> 
       @using (Html.BeginForm()) 
       { 

        <td>Select customer Name</td> 
        <td> 

         @Html.DropDownListFor(m => m.customer_id, new SelectList(Model.customerList, "customer_id", "customer_business_name")) 
         <input type="hidden" id="hdnCustomerName" name="hdnCustomerName" /> 
         <input type="hidden" id="hdnShowHideCustInfo" name="hdnShowHideCustInfo" /> 
         <input type="submit" value="Go" name="Go" id="Go" /> 
         </td>     

       } 
      </tr> 

     </table> 

    </div> 




     @if (Model.objectOfServiceListDevice != null) 
     { 
      @Html.Partial("Devices", Model.objectOfServiceListDevice) 
     } 

回答

0

我會嘗試更換此:

@if (Model.objectOfServiceListDevice != null) 
{ 
    @Html.Partial("Devices", Model.objectOfServiceListDevice) 
} 

有了這個:

<div id="myGrid"> 
    @Html.Partial("Devices", Model.objectOfServiceListDevice) 
</div>