2

I'm currently try to use the JQuery Datatables in my Project. This seem to work quite well, but I have problems to process the Ajax request for removing a row.

The Ajax request that is send by the datatables Editor plugin is formatted like:

action=remove&table=pzeIpMaster&id=&data%5B%5D=3

The method in the controller looks like

[Authorize, HttpPost]
public ActionResult OnDeletePzeMaster(
  string action, string table, string id, string[] data)

The values of the parameters are

  • action = remove
  • table = pzeIpMaster
  • id = ""
  • data = null

Why is data set to null ?!! In my opinion data must be set to {3}

Thx for your help

tereško
  • 58,060
  • 25
  • 98
  • 150
BitKFu
  • 3,649
  • 3
  • 28
  • 43

1 Answers1

2

data%5B%5D decodes to data[]. So MVC can't match data[] with yor data parameter.

You could try this:

[Authorize, HttpPost]
public ActionResult OnDeletePzeMaster(
  string action, string table, string id)
{
var data = this.Request.Form["data[]"];
}

Or you could write a ModelBinder like this

ASP.NET MVC - Custom model binder able to process arrays

Community
  • 1
  • 1
Oliver
  • 1,225
  • 10
  • 19