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!