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

[Solved] Problem deleting from Telerik grid

1 Answer 44 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.
Nigel
Top achievements
Rank 1
Nigel asked on 29 Nov 2010, 04:10 PM
Hi,

I have a grid as follows in my view:

             <% Html.Telerik().Grid(Model.RegisterDocuments)
                  .Name("RegisterDocumentGrid")
                  .DataKeys(keys => { keys.Add(o => o.ID); })
                  .DataBinding(dataBinding => {
                                 dataBinding.Ajax()
                                   .Select("_AjaxBinding", "Documents", ViewData.Model.RegisterHeader.Id)
                                   .Delete("_DeleteAjaxEditing", "Documents");
                               })
                  .Columns(columns => {
                             columns.Bound(o => o.ID).Title("ID");
                             columns.Bound(o => o.File.OriginalFilename).Title("Document Name");
                             columns.Bound(o => o.MimeType).Title("Document Type");
                             columns.Bound(o => o.CreationDate).Format("{0:dd/MM/yyyy}").Title("Date Added");
                             columns.Bound(o => o.UserID).Title("Added By");
                             //columns.Command(commands => commands.Delete().ButtonType(GridButtonType.Text)).Title("");
                             columns.Command(commands => {
                                               commands.Delete().ButtonType(GridButtonType.Text);
                                             }).Width(180).Title("Commands");
                           }).Footer(false)
                  .Render();
%>


and in my Controller I have the following function:

 

[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult _DeleteAjaxEditing(int documentId) {
  //do some stuff.....
}

Now if I try to delete a row from my grid I get a 500 Internal Server error. If I look at it in firebug I get the following error message:

"The parameters dictionary contains a null entry for parameter 'documentId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult _DeleteAjaxEditing(Int32)' in 'AsbestosRegister.Web.Controllers.Asbestos.DocumentsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters"


So....obviously it is expecting an int to be passed as a parameter into _DeleteAjaxEditing. I have based mine of the examples online e.g. http://demos.telerik.com/aspnet-mvc-beta/grid/editingajax and it doesn't pass an int into it's delete method which has an int as a parameter.

What am I doing wrong?!

Any help much appreciated.

1 Answer, 1 is accepted

Sort by
0
alex
Top achievements
Rank 1
answered on 07 Jun 2011, 09:19 AM
Hi.
Try to use instead of documentId - ID.

Like this:

[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult _DeleteAjaxEditing(int ID) {
  //do some stuff.....
}
Tags
Grid
Asked by
Nigel
Top achievements
Rank 1
Answers by
alex
Top achievements
Rank 1
Share this question
or