We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error Deleting row in Grid Control

Thread ID:

Created:

Updated:

Platform:

Replies:

124268 May 27,2016 01:00 PM UTC May 30,2016 08:20 AM UTC ASP.NET MVC 1
loading
Tags: Grid
André Secco
Asked On May 27, 2016 01:00 PM UTC

Hello,
I'm have a problem to delete row in Grid Control, but the following error appears:

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Remove(Int32)' in 'Test.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.

Nome do parâmetro: parameters


Following the code I use:

View:

 @(Html.EJ().Grid<object>("Editing")
                    .Locale("pt-BR")
                    .Datasource(ds => ds.Json(Model).RemoveURL("Home/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor))
                    .AllowScrolling()
                    .IsResponsive(true)
                    .AllowKeyboardNavigation()
                    .AllowFiltering()
                        .FilterSettings(filter =>
                        {
                            filter.FilterType(FilterType.Excel);
                        })
                    .AllowSorting()
                    .AllowMultiSorting()
                    .AllowResizing()
                    .EditSettings(e => e.AllowDeleting())
                    .Columns(col =>
                     {
                         col.Commands(command =>
                         {
                             command.Type(UnboundType.Edit)
                                    .ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
                                    {
                                        Text = "Editar",
                                        ContentType = ContentType.TextAndImage,
                                        Width = "80",
                                        PrefixIcon = "e-edit"
                                    }).Add();
                             command.Type(UnboundType.Delete)
                                    .ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
                                    {
                                        Text = "Excluir",
                                        ContentType = ContentType.TextAndImage,
                                        Width = "80",
                                        PrefixIcon = "e-delete"
                                    }).Add();
                         }).Width(25).Add();
                         col.Field("ID").HeaderText("ID").IsPrimaryKey(true).Width(20).Add();
                         col.Field("Nome").HeaderText("Nome").Width(120).Add();
                         col.Field("DataModificacao").HeaderText("Data de Modificação").Width(40).Format("{0:MM/dd/yyyy}").Add();
                     })

Controller: 

        [HttpPost, ActionName("Remove")]
        public ActionResult DeleteConfirmed(int id)
        {
            PISRegra pisRegra = db.Regras.Find(id);
            db.Regras.Remove(pisRegra);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

Thanks for help!

Jayaprakash Kamaraj [Syncfusion]
Replied On May 30, 2016 08:20 AM UTC

Hi André, 

Thank you for contacting Syncfusion support. 

We need to pass the parameter as “key” while performing delete operation at server side by using RemoveURL property. Please refer to the below code example, sample and Help document.   
 
GridFeatures.cshtml 
  .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).InsertURL("/Grid/PerformInsert") 
                                .UpdateURL("/Grid/PerformUpdate") 
                                .RemoveURL("/Grid/PerformDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) 
 
GridController.cs 
public ActionResult PerformDelete(int key) 
        { 
 
            db.OrderTables.Remove(db.OrderTables.Single(o => o.OrderID == key)); 
            db.SaveChanges(); 
            var data = db.OrderTables.ToList(); 
            return Json(data, JsonRequestBehavior.AllowGet); 
        } 
 
 
 
Regards, 
 
Jayaprakash K. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;