Null Data Value in ASP MVC
Null Data Value in ASP MVC
Hi everyone,
Firstly thanks for a great product!
I am testing out the new Editor for Datatables using ASP.Net MVC and am having a problem getting the data back for the row to be updated.
Basically when I click update I can see (using FireBug) that it is posting back a data object which contains the fields and their values. However, when I break execution in Visual Studio the 'table' field has a value but the data object is always null...
I'm thinking that I'm using the wrong sort of input parameter on the UpdateData method?
Hoping someone might be able to point out my mistake!
Thanks,
Nick
[code]
//Controller Code
public string UpdateData(string table, object data)
{
// Do stuff
}
var editor;
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
"ajaxUrl": '@Url.Action("UpdateData","Test")',
"domTable": "#Testing",
"dbTable": "Testing",
"fields": [
{
"label": "Field 0:",
"name": "Field0",
"type": "readonly",
"dataProp": 0
}, {
"label": "Field1:",
"name": "Field1",
"type": "readonly",
"dataProp": 1
},
...........
]
});
$('#Testing').dataTable({
"bAutoWidth": false,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"sDom": 'T<"clear">W<"clear">lfrtip',
"aoColumnDefs": [{ "bVisible": false, "aTargets": [3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 17, 18, 19, 20]}],
"oColumnFilterWidgets":
{
"aiExclude": [1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20]
},
"oTableTools":
{
"sRowSelect": "multi",
"sSwfPath": "../../Scripts/copy_csv_xls_pdf.swf",
"aButtons":
[
{ "sExtends": "editor_edit", "editor": editor },
"copy",
"print",
{
"sExtends": "csv",
"sButtonText": "Save As CSV"
}
]
}
});
[/code]
Firstly thanks for a great product!
I am testing out the new Editor for Datatables using ASP.Net MVC and am having a problem getting the data back for the row to be updated.
Basically when I click update I can see (using FireBug) that it is posting back a data object which contains the fields and their values. However, when I break execution in Visual Studio the 'table' field has a value but the data object is always null...
I'm thinking that I'm using the wrong sort of input parameter on the UpdateData method?
Hoping someone might be able to point out my mistake!
Thanks,
Nick
[code]
//Controller Code
public string UpdateData(string table, object data)
{
// Do stuff
}
var editor;
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
"ajaxUrl": '@Url.Action("UpdateData","Test")',
"domTable": "#Testing",
"dbTable": "Testing",
"fields": [
{
"label": "Field 0:",
"name": "Field0",
"type": "readonly",
"dataProp": 0
}, {
"label": "Field1:",
"name": "Field1",
"type": "readonly",
"dataProp": 1
},
...........
]
});
$('#Testing').dataTable({
"bAutoWidth": false,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"sDom": 'T<"clear">W<"clear">lfrtip',
"aoColumnDefs": [{ "bVisible": false, "aTargets": [3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 17, 18, 19, 20]}],
"oColumnFilterWidgets":
{
"aiExclude": [1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20]
},
"oTableTools":
{
"sRowSelect": "multi",
"sSwfPath": "../../Scripts/copy_csv_xls_pdf.swf",
"aButtons":
[
{ "sExtends": "editor_edit", "editor": editor },
"copy",
"print",
{
"sExtends": "csv",
"sButtonText": "Save As CSV"
}
]
}
});
[/code]
This discussion has been closed.
Replies
[AcceptVerbs(HttpVerbs.Post)]
public string UpdateData()
{
string Field0= Request.Form["data[Field0]"];
.....
}
Not sure if this is the best way, but it works!