Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml.Grid can't find a model property that is clearly there
    primarykey
    data
    text
    <p>The grid in question is a simple list of locations, based on this collection:</p> <pre><code>public class Locations : BaseGrid { public string zipCode { get; set;} public string city { get; set; } public string state { get; set; } public string timeZone { get; set;} public IPagination&lt;Location&gt; LocationList { get; set; } } </code></pre> <p>and this entity:</p> <pre><code>[DataContract] // DataContract/DataMember used for JsonSerializer public class Location { public int ID { get; set; } public string Address; public string AlternateSupportingLocationNumber; public string City; public string CompanyName; [DataMember] public string CTU; public string Description; public double Distance; [DataMember] public string LocationNumber; public string ManagerName; public string PhoneNumber; public string State; public string SupportingLocationNumber; public string TimeZone; public string ZipCode; public bool IsInPhysicalInventory; public bool IsEslOwned; } </code></pre> <p>The controller, which looks like this:</p> <pre><code> public ActionResult NearestStoreCoverage( Locations locations ) { if ( string.IsNullOrEmpty( locations.SortBy ) ) locations.SortBy = "Distance"; var list = _locationService.NearestStoreCoverage( locations, 50, ModelState ); locations.LocationList = list.AsPagination(locations.Page ?? 1, list.Count); //go get locations that are close return View( "Details/NearestStoreCoverage", locations ); } </code></pre> <p>Gets the view a list of Locations as a LocationList member of the Locations model, and populates this control:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;Locations&gt;" %&gt; &lt;%@ Import Namespace="Models.Common"%&gt; &lt;div class="detailSection" style="width:98%"&gt; &lt;h1&gt;Locations close to Zip Code -- &lt;%=Model.zipCode %&gt;&lt;/h1&gt; &lt;div&gt; &lt;%= Html.Grid(Model.LocationList).Columns(column =&gt; { column.For(x =&gt; x.LocationNumber) .Named(Html.SortByLink("Location","LocationNumber")); column.For(x =&gt; x.Distance.ToString("N2")).Named( Html.SortByLink("Distance", "Distance")); column.For(x =&gt; x.PhoneNumber.ToFormattedString()). Named(Html.SortByLink("Phone Number", "PhoneNumber")); column.For(x =&gt; x.Address).Named( Html.SortByLink("Address", "Address")); column.For(x =&gt; x.City).Named( Html.SortByLink("City", "City")); column.For(x =&gt; x.State).Named( Html.SortByLink("State", "State")); column.For(x =&gt; x.ZipCode).Named( Html.SortByLink("ZipCode", "ZIpCode")); }) .Attributes(style =&gt; "width:100%") .Attributes(id =&gt; "locationClosesttoZipGrid") .Empty("There are no locations close to this zipcode") %&gt; &lt;%= Html.Pager( Model.LocationList ).Link( page =&gt; Html.WritePageLink( page ) )%&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Whren this is run, the runtime error is </p> <pre><code>System.ArgumentException was unhandled by user code Message=The property Models.Common.Location.LocationNumber could not be found. Source=System.Web.Mvc InnerException: </code></pre> <p>(I removed the stack trace for the client, it is boring anyway)</p> <p>However, if you debug and look at the Model (this is from Html.Grid(Model.LocationList).Columns), you can clearly see that LocationNumber is populated:</p> <p><a href="http://img839.imageshack.us/img839/6538/34gridresults.png" rel="nofollow noreferrer">A look at the Model in the debugger http://img839.imageshack.us/img839/6538/34gridresults.png</a></p> <p>Think it can't get stranger? If I comment out the reference to the LocationNumber, the debugger allows the Distance and Phone Number, and then fails again on Address (which is also clearly there).</p> <p>I have tried a rebuild, and have F12ed all of the relevant symbols to make sure they go where I think they should go.</p> <p>The debugger won't let me look at x, which is a bummer. Any idea what could be wrong, or at least how to start looking?</p>
    singulars
    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.
    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