2

I'm trying to bind a DataTable from my controller to a kendo UI grid on a click event. Problem is I'm having a problem to parse the DataTable to the View(via Ajax).

// myController.cs  to return the DataTable Object.
        public DataTable myMethod(string source)
                {
                    string connection = "myConnectionString" 
                    using (var dataAdapter = new OracleDataAdapter("SELECT * from myTable", connection))
                    {
                        var dataTable = new DataTable();

                        dataAdapter.Fill(dataTable);
                        dataAdapter.FillSchema(dataTable,SchemaType.Source);

                        return dataTable;
                    }
            }

View (cshtml)

function Btn_click(e) {
            $.ajax({
                url: '/myController/myMethod',
                contentType: "application/json; charset=utf-8",
               },
                type: 'GET',

            })
             .success(function (data) {
                 var grid = $("#myGrid").data("kendoGrid");
                 // destroy it
                 grid.destroy();
                 $("#myGrid")
                     .empty() // clear the old HTML
                     .kendoGrid({
                         dataSource: {
                             data: data,
                         }
                     });

             })

I'm getting errorParse on the view when I run this ...what is the better way? for binding.

  • possible duplicate of [How to bind Kendo Grid with System.Data.DataTable at runtime](http://stackoverflow.com/questions/24909618/how-to-bind-kendo-grid-with-system-data-datatable-at-runtime) – Jarosław Kończak Jun 19 '15 at 16:14
  • MVC could not return DataTable type, follow proper syntax – Neo Vijay Jun 20 '15 at 06:06

0 Answers0