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

Index Out Of Range Exception in GridBuilder

1 Answer 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yasser Moradi
Top achievements
Rank 1
Yasser Moradi asked on 01 Oct 2012, 11:15 AM
Hi ,
I've developed a few lines of code with ASP.NET MVC wrappers of Telerik
A Customer Entity with ID , Name , Rate
Entity Framework Code First Context
A Controller with this code : 

public ActionResult Index()
        {
            return View();
        }
 
        public ActionResult Customers([DataSourceRequest] DataSourceRequest request)
        {
            var customers = Context.Customers.ToDataSourceResult(request);
            return Json(customers);
        }

and a view with this code

@(Html.Kendo().Grid<Customer>()
    .Name("CustomersGrid")
    .Columns(columns =>
    {
        columns.Bound(c => c.ID).Groupable(false);
        columns.Bound(c => c.FName);
        columns.Bound(c => c.LName);
        columns.Bound(c => c.Rate);
    })
        .Groupable()
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable()
        .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("Customers", "Customer"))
    )
)

when render of view finishes at the end of @HTML.Kendo
I give this exception

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


Line 19:         .Scrollable()
Line 20:         .Filterable()
Line 21:         .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("Customers", "Customer"))
Line 22:     )
Line 23: )

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.ThrowHelper.ThrowArgumentOutOfRangeException() +72
   System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value) +10419142
   System.Web.Mvc.ControllerContext.get_RequestContext() +25
   Kendo.Mvc.UI.NavigatableExtensions.GenerateUrl(INavigatable navigatable, ViewContext viewContext, IUrlGenerator urlGenerator) +52
   Kendo.Mvc.UI.Fluent.CrudOperationBuilder.SetUrl() +81
   Kendo.Mvc.UI.Fluent.CrudOperationBuilder.Action(String actionName, String controllerName, Object routeValues) +66
   Kendo.Mvc.UI.Fluent.CrudOperationBuilder.Action(String actionName, String controllerName) +47
   ASP._Page_Views_Customer_Index_cshtml.<Execute>b__1(CrudOperationBuilder read) in c:\Users\a.rezaei\Desktop\MVCWebApp\MVCWebApp\Views\Customer\Index.cshtml:21
   Kendo.Mvc.UI.Fluent.AjaxDataSourceBuilderBase`2.Read(Action`1 configurator) +131
   ASP._Page_Views_Customer_Index_cshtml.<Execute>b__0(DataSourceBuilder`1 dataSource) in c:\Users\a.rezaei\Desktop\MVCWebApp\MVCWebApp\Views\Customer\Index.cshtml:21
   Kendo.Mvc.UI.Fluent.GridBuilder`1.DataSource(Action`1 configurator) +212
   ASP._Page_Views_Customer_Index_cshtml.Execute() in c:\Users\a.rezaei\Desktop\MVCWebApp\MVCWebApp\Views\Customer\Index.cshtml:7


Extra Info

Windows : 8 , Visual Studio Development Server , Visual Studio 2012 , .NET 4.5 , MVC 4 , Kendo UI MVC Wrappers v2012.2.710
 
thanks for your support

1 Answer, 1 is accepted

Sort by
0
Yasser Moradi
Top achievements
Rank 1
answered on 02 Oct 2012, 06:00 AM
Downgrading to ASP.NET 3 would be handy
Tags
Grid
Asked by
Yasser Moradi
Top achievements
Rank 1
Answers by
Yasser Moradi
Top achievements
Rank 1
Share this question
or