Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Return partial view on asp.net mvc
    primarykey
    data
    text
    <p>The following code will not works on server after hosting,but it works fine on localhost. Is there is any problem on code.</p> <p><strong>Controllers:</strong></p> <pre><code>[HttpGet] public ActionResult SelectCustomerByID(Receipt model, string secondValue) { int CustID = 0; if (secondValue != null &amp;&amp; secondValue != "") CustID = Convert.ToInt32(secondValue); ObservableCollection&lt;Receipt&gt; ReceiptList = new ObservableCollection&lt;Receipt&gt;(); Receipt Receipt = new Models.Receipt(); if (CustID != 0) ReceiptList = Receipt.GetReceiptListByCustID(CustID); else ReceiptList = Receipt.GetReceiptList(); ViewData["Count"] = ReceiptList.Count; return PartialView("_Recepitgrid", ReceiptList); } </code></pre> <p>SCRIPT IN PARTIAL VIEW:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { var str = ('@ViewData["Count"]'); if (str == '0') ShowProduct(); else ShowGrid(); }); function ShowProduct() { document.getElementById("gridContent").style.display = 'none'; document.getElementById("ShowNodata").style.display = 'block'; return false; } function ShowGrid() { document.getElementById("gridContent").style.display = 'block'; document.getElementById("ShowNodata").style.display = 'none'; return false; } &lt;/script&gt; </code></pre> <p>PartialView:</p> <pre><code> &lt;div id="divgrid" &gt; @{ var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent"); grid.Pager(WebGridPagerModes.NextPrevious);} &lt;div id="gridContent" class="rounded-corners"&gt; @grid.GetHtml( tableStyle: "webgrid-table", headerStyle: "webgrid-header", footerStyle: "webgrid-footer", alternatingRowStyle: "webgrid-alternating-row", selectedRowStyle: "webgrid-selected-row", rowStyle: "webgrid-row-style", columns: grid.Columns( grid.Column(header: "S.No", format: item =&gt; Item.WebGrid.Rows.IndexOf(item) + 1), grid.Column("Recepit_No", "Recepit Number", style: "PName"), grid.Column(null, null, format: @&lt;input type="hidden" name="Id" id="ID" value="@item.ID"/&gt;), grid.Column("Cust_Name", "Cust Name", style: "PName"), grid.Column("Pay_Amount", "Paid Amount", style: "Curency"), grid.Column("Pay_Mode", "Paid Mode", style: "IName"), grid.Column("Bank_Name", "Bank Name", style: "Weight"), grid.Column("Bank_Address", " Bank Address", style: "MakingCharge"), grid.Column("ChequeNo", "ChequeNo", style: "Certification"), grid.Column("Cheque_Date", " Cheque Date", style: "Price"), grid.Column("Date", "Date", format: item =&gt; ((item.Date == null) ? "" : item.Date.ToString("dd/MM/yyyy")), style: "Price"), grid.Column("Edit", "", @&lt;a href='../Admin/EditReceipt?Id=@item.Id' &gt;&lt;img src="~/Images/edit.png" alt='Edit' /&gt;&lt;/a&gt;, style: "width:10%"), grid.Column(header: "Delete", format: @&lt;text&gt;&lt;a href="@Url.Action("DeleteReceipt", "Admin", new { Id = item.ID })" onclick="javascript:return confirm('Are you sure you'd like to delete this product?');"&gt;&lt;img src="../Images/delete.png" alt='Delete' /&gt;&lt;/a&gt;&lt;/text&gt;) )) &lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload