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

[Solved] AJAX Databinding with ASP.Net MVC 3 Razor - HTTP 500 Popup

1 Answer 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Missing User
Missing User asked on 05 Jun 2012, 10:26 AM
Hi,

I am trying to convert my Client Index View to use a Telerik Grid to display the clients. I have been reading through some examples and I am following the following Demo:
http://demos.telerik.com/aspnet-mvc/razor/grid/ajaxbinding

However when I am trying to test my code I get a popup as soon as grid databinds, saying: "Error! The requested URL returned 500 -error"

If I debug the Action in the controller all seem fine untill I step out of the Action then the debugger tries to locate a file called "GridActionAttribute.cs" in the following directory:
"Locating source for 'f:\114\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\GridActionAttribute.cs"

Here is my View:
@model IEnumerable<MUMSUtilities.Client>
@using Telerik.Web.Mvc.UI
@{
    ViewBag.Title = "Client Index";    
}
  
<h2>Client Index</h2>
  
<p>
    @Html.ActionLink("Create New", "Create")
</p>
  
@(Html.Telerik().Grid<MUMSUtilities.Client>("Clients")
    .Name("Grid")
    .Columns(columns => 
    { 
        columns.Bound(c => c.ClientName); 
    })
    .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxBinding", "Client"))
    .Pageable()
    .Sortable()
    .Scrollable()
    .Groupable()
    .Filterable())

And my Controller Action:
[GridAction]
public ActionResult AjaxBinding()
{
    var clients = db.Clients.ToList();
    return View(new GridModel<Client> { Data = clients, Total = clients.Count });
}


Any idea why the Databind is not working correctly?

Kind Regards,
Paul

1 Answer, 1 is accepted

Sort by
0
Licenses
Top achievements
Rank 1
answered on 05 Jun 2012, 12:17 PM
Try remove the "Clients":

@(Html.Telerik().Grid<MUMSUtilities.Client>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.ClientName);
    })
    .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxBinding", "Client"))
    .Pageable()
    .Sortable()
    .Scrollable()
    .Groupable()
    .Filterable())


You should also have a look at your firebug / fiddler to see the server response. The response should be a normal ASP.NET error page and should display the error that is happening.

And instead of using Telerik's GridModel, it is sufficient to just return JSON data:

[GridAction]
public ActionResult AjaxBinding()
{
    var clients = db.Clients.ToList();
    return Json(clients);
}
Tags
Grid
Asked by
Missing User
Answers by
Licenses
Top achievements
Rank 1
Share this question
or