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

[Solved] 500 Internal Server Error on Insert ONLY on Ajax bound grid.

2 Answers 161 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.
Michael
Top achievements
Rank 1
Michael asked on 26 Oct 2010, 05:35 PM
Error: The Requested URL Returned 500 - Internal Server Error
Version: 2010.2.825.235

I get the 500 Internal Server Error on an AJAX Bound grid doing an insert only. 
See code below:
        [AcceptVerbs(HttpVerbs.Post)]
      [GridAction]
      public ActionResult _InsertAjaxEditing()
      {
 
 
          var model = new SpecialEventViewModel();
          //Perform model binding (fill the product properties and validate it).
          if (TryUpdateModel(model))
          {
              //The model is valid - insert the product.
              _service.Save(model);
          }
          GetViewData();
          //Rebind the grid
          return View(_service.GetAll());
      }

The GetViewData call gets the items needed for a combo box:
public void GetViewData()
        {
 
            ViewData[ViewDataKeys.Locations] = new SelectList(_locService.GetAll(), "CommitteeLocationId", "LocationName");
        }


I have stepped through every line of the code up to and including the "GetAll()" that gets called to pass the items back to the grid and there are no errors on the whole trip.  I've checked the collection that gets returned to the grid and there is no invalid or duplicate data.  There's nothing that would cause an exception.

There are no circular references as my item uses only basic .NET types.  It's a View Model that is created separately (I'm not using EF anyways). 

The kicker is, the item ACTUALLY INSERTS, but the grid throws the error and it stays in Edit mode.  I can select, update, and delete the same item that was inserted that threw an error and I have no issues.

The ScriptManager is at the BOTTOM of the Site.Master right before the last </body> tag.

This only happens on insert.

Does anyone have any suggestions?


2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 26 Oct 2010, 05:44 PM
Hello Michael,

 Unless your GetAll method returns a GridModel object you need to modify your code:

return View(new GridModel(_service.GetAll()));

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 26 Oct 2010, 05:49 PM
I can't tell you how many times I overlooked that.  I compared it to my "Update" action method and swore up and down they were identical, however the "Update" method created a grid model.

Thanks.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or