This is a migrated thread and some comments may be shown as answers.

ArgumentOutOfRangeException in Grid bound to a List with very simple object.

4 Answers 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pedro
Top achievements
Rank 1
Pedro asked on 20 Jun 2012, 05:12 PM
The grid is bound like this:
 
@(Html.Kendo().Grid(Model).Name("organizationsGrid"))

The action is like this:

var model = new List<OrganizationSummaryModel> {
                new OrganizationSummaryModel { Code = "Xyz", Description = "Xyz Organization" },
                new OrganizationSummaryModel { Code = "Abc", Description = "Abc Organization" }
            };


return View(model); Throws this exception: System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +64 System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item) +10635094 Kendo.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) +746 Kendo.Mvc.UI.ViewComponentBase.ToHtmlString() +115 Kendo.Mvc.UI.ViewComponentBuilderBase`2.ToHtmlString() +62 System.Web.HttpUtility.HtmlEncode(Object value) +38 System.Web.WebPages.WebPageBase.Write(Object value) +68 ASP._Page_Views_account_SelectOrganization_cshtml.Execute() Using: Visual Studio 2010 with MVC 4 RC.

4 Answers, 1 is accepted

Sort by
0
Bert
Top achievements
Rank 1
answered on 03 Jul 2012, 12:38 AM
I am currently trying to use KendoUI as a frontend solution for a new company using the newest technologies. KendoUI is one of the most wanted control suites, however:

I experience the exact same problem at my end. I have a list of products which should be bound to the grid. However, it always comes with the ArgumentOutOfRangeException. The example code is working. Unfortunately, I cannot figure out what I am doing wrong? Is there any help on this situation?

As an extra: I am using Visual Studio 2012 RC, ASP.NET MVC 4. The exception is exactly as Pedro's.
0
Accepted
Atanas Korchev
Telerik team
answered on 03 Jul 2012, 06:32 AM
Hi,

 For some reason I can't reproduce this problem. Find attached my test project.

Greetings,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Bert
Top achievements
Rank 1
answered on 03 Jul 2012, 09:03 PM
Hi,

Thanks for your support! Really appreciated!

Your example works on my machine as well. I stripped my project until I got it working. After all, at my place there was something missing in the web.config file:

<

dependentAssembly>
  <
assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <
bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</
dependentAssembly>
<
dependentAssembly>
  <
assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <
bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</
dependentAssembly>

When I added those lines to my web.config, the problem was gone. It seems the ASP.NET MVC 4 RC project template does not add those lines by default, where I would have liked that a lot ;) .

@Pedro: I wonder if this solves your problem too?

0
Pedro
Top achievements
Rank 1
answered on 04 Jul 2012, 08:35 AM
Hi,

Yes this solved it on my case to. Thanks a lot!!!

Pedro
Tags
Grid
Asked by
Pedro
Top achievements
Rank 1
Answers by
Bert
Top achievements
Rank 1
Atanas Korchev
Telerik team
Pedro
Top achievements
Rank 1
Share this question
or