0

I have generated javascript datatable in asp.net. I have brought data using webservice. It is displaying perfectly. I have made the cells editable. But I don't know how to write code for editing. My code is as follows:

    $('#showData').dataTable().makeEditable({
            //"bDestroy": true,
            "sPaginationType": "full_numbers",
            sUpdateURL: "UpdateData.cs"
    "aoColumns": [
                   null,
                   null,
                   null,
                   {
                       indicator: 'Saving Payment Clearance Date...',
                       tooltip: 'Click to edit platforms',
                       type: 'textarea',
                       submit: 'Save changes',
                   }
            ]
        });

I just want to update last column and it provides save button. Now my question is where to impelement UpdateData.cs? Shall I make a class file? How to pass value and row id in that function? Google shows links about php and .net MVC only.

Have used following files:

jquery.dataTables.css

jquery.dataTables.min.js

jquery.dataTables.editable.js

jquery.jeditable.js

jquery.validate.js
Ami
  • 397
  • 2
  • 4
  • 19
  • You can try with a `[WebMethod]` inside `UpdateData.cs` and then it should look something like this `sUpdateURL: "UpdateData.cs\MyUpdateMethod"`. I personally am using `.ashx` file as http handle, where I can use the `HttpContext`. Don't know which one is better, but `.ashx` serves me well even though it has some mahor disadvantages. – Leron Oct 20 '14 at 07:03
  • Leron if I use class file than why do I require to write [WebMethod] for that? I can directly write what all editing I want in class file itself – Ami Oct 20 '14 at 07:20
  • If you can, then go with it. I highly doubt that you can use datatable without using webmethod or some sort of http handler.. – Leron Oct 20 '14 at 07:27
  • No I dont want to reload page every time. – Ami Oct 20 '14 at 07:30
  • Then use `[WebMethod]` or `HttpHandler`. – Leron Oct 20 '14 at 07:40
  • Can you please elaborate how to use it and how to pass value and id o webmwthod – Ami Oct 20 '14 at 09:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/63334/discussion-between-ami-and-leron). – Ami Oct 20 '14 at 10:36
  • @Ami you havent specified if you are using ASP.NET MVC or WebForms. If you don't want to postback, then you need to use javascript to call your server-side code and the only way to do this is through either a [WebMethod] or a WebAPI call. Once you decide on the best solution, we can provide you with a sample implementation – Chris Oct 20 '14 at 10:38
  • I have added a line 'Google shows links about php and .net MVC only'.So it would be MVC than I would have done. But I am using WebForm. How can I pass value and id to [WebMethod]? – Ami Oct 20 '14 at 10:47
  • @Ami I need to finish something and then I'm gonna copy/paste you how I use `DataTable` with `WebForms` using `.ashx` file. To modify it so you can use `[WebMethod]` should be trivial, but since I have written code for `.ashx` I'm gonna show it to you and hopefully you will get going with either `.ashx` or webmethods in `.cs` files. – Leron Oct 20 '14 at 11:19
  • Ok. Thanks.. Get me the code when you complete your work. – Ami Oct 20 '14 at 11:22
  • Well, even better. Few months ago I found this answer here - http://stackoverflow.com/questions/3531438/jquery-datatables-server-side-processing-using-asp-net-webforms which get me going. Darin Dimitrov is exceptional professional. His example works perfectly so it might be better to start off by implementing it and then change things one by one until you reach your desired result. – Leron Oct 20 '14 at 11:35
  • That is not my cup of tea. It is showing about sorting and searching. I want to update the field which is edited in datatable. I don't know what value to be fetched in context.Request[]. – Ami Oct 20 '14 at 11:55
  • I'm afraid I can't help you any further. Most probably if you examine the returned `params` you will see your edited value there. But I'm not sure. – Leron Oct 20 '14 at 12:16
  • Than calling [WebMethod] from .cs file is good option because I don't know anyting about generic handlers – Ami Oct 20 '14 at 12:24

0 Answers0