jquery datatable编辑器插件无法在asp.net中工作(c#)

时间:2012-11-21 16:47:59

标签: c# jquery asp.net jquery-datatables-editor

我正在使用数据表编辑器插件将行插入数据表中,但它无法正常工作。请参阅下面的代码。

// Create the form
editor = new $.fn.dataTable.Editor({
    "ajaxUrl": {
        "create": 'Default.aspx/InsertNewuser'
    },
    "domTable": "#tbl",
    "fields": [{
            "label": "FirstName:",
            "name": "FirstName"
        },
        {
            "label": "LastName:",
            "name": "LastName"
        }]
});

新行代码:

// New record
$('a.editor_create').on('click', function (e) {
  e.preventDefault();
  editor.create(
    'Create new record', {
      "label": "Add",
      "fn": function () {
        editor.submit();
      }
    });
})

来自Default.aspx.cs的c#代码:

[WebMethod]
public static int InsertNewuser(string FirstName, string LastName)
{
    DataClasses1DataContext db = new DataClasses1DataContext();
    student1 table = new student1();

    table.FirstName = FirstName;
    table.LastName = LastName;

    db.student1s.InsertOnSubmit(table);
    db.SubmitChanges();
    return table.Std_ID;
}

0 个答案:

没有答案