- Home
- Forum
- ASP.NET MVC
- Error Deleting row in Grid Control
Error Deleting row in Grid Control
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!
SIGN IN To post a reply.
1 Reply
JK
Jayaprakash Kamaraj
Syncfusion Team
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);
} |
Sample: http://www.syncfusion.com/downloads/support/forum/124268/ze/SyncfusionMvcApplication29-256155834
Help Document: http://help.syncfusion.com/aspnetmvc/grid/editing?cs-save-lang=1&cs-lang=csharp#delete-record
Regards,
Jayaprakash K.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
AS André Secco
- May 27, 2016 01:00 PM UTC
- May 30, 2016 08:20 AM UTC