ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Count must have a non-negative value. When binding to a grid
Title:
B
I
{code}
?
Please see the code below : I am seeing the System.ArgumentException was unhandled by user code. Complete stack trace is below the method. Any ideas on how to resolve the issue. public JsonResult GetHistory(GridParams g, int id) { var query = _context.TestEvents; var model = new GridModelBuilder<TestEvent>(query.AsQueryable(), g) { Key = "Id", Map = MapHistoryEntityToGridModel, }.Build(); return Json(model); } private object MapHistoryEntityToGridModel(TestEvent o) { return new TestEventViewModel { Id = o.Id, Description = o.Description, Createdby = o.Createdby }; } view: <div class="row-sub"> @(Html.Awe().Grid("G5") .Url(Url.Action("GetHistory", "TestRequest")) .Columns( new Column { Name = "Name", Header = "Name", Width = 150 }, new Column { Name = "Description", Header = "Description", Width = 150 }, new Column { Name = "CreatedBy", Header = "Created By", Width = 150 } ) .Sortable(false) .PageSize(20) .Groupable(false)) </div> The stack trace System.ArgumentException was unhandled by user code HResult=-2147024809 Message=Count must have a non-negative value. Parameter name: count Source=EntityFramework ParamName=count
Save Changes
Cancel
ajaywebdev
asked at 07 Oct 2015
We are using 4.7.3. I dont believe we ever had similar issue with older versions.
at 07 Oct 2015
ajaywebdev
you will get this if g.Page is -1, please check (debug) and make sure that's not the case
at 07 Oct 2015
Omu
g.Page = 0. Please see this link for all the gridParam values https://www.dropbox.com/s/1ujfreoc902931w/2015-10-06%2022_06_12-New%20notification.png?dl=0
at 07 Oct 2015
ajaywebdev
page = 0 is the problem, please try to open your page in incognito window (private mode Ctrl+Shift+N on chrome), also please post the markup (view) code for the grid
at 07 Oct 2015
Omu
Same issue in Incognito mode. Please see here https://www.dropbox.com/s/j7fijtusffne2c0/2015-10-07%2007_05_25-New%20notification.png?dl=0 I updated the original question with view
at 07 Oct 2015
ajaywebdev
When I have the same grid, in a regular page that it works fine. In our scenario, this grid is in a partial view that is loaded on demand. How can we make the grid work when it is loaded via Ajax?
at 07 Oct 2015
ajaywebdev
a workaround would be to do: if(g.Page < 1) g.Page = 1; the questions is why page is 0, if you could reproduce this in a sample project that will help a lot: http://aspnetawesome.com/learn/mvc/CommonProblems#Isolate-the-problem how are you loading the partial view ?
at 07 Oct 2015
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK