Hello everyone,
I am trying to get kendo grid data with ado.net. But this code does not include kendo grid data.
I just want the data to come when I press the search button.
What is the problem?
Can you make an example with the code I shared?
Controller
            System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString);
            sqlConnection.Open();
            string email = "email";
            string odemetakip = "select TOP 1 O.OrderId from Customer C INNER JOIN OdemeTakip O ON O.CustomerId = C.Id Where C.Email=@email order by O.OrderId desc";
            System.Data.SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand(odemetakip, sqlConnection);
            sqlCommand.Parameters.AddWithValue("email", email);
            System.Data.SqlClient.SqlDataReader sqlDataReaders = sqlCommand.ExecuteReader();
            string odemetakipdetay = "select OT.OrderId,OT.BankResponseContent,OT.ShortErrorMessage,OT.CreatedOnUtc from OdemeTakipDetay OT Where OT.OrderId=@odemetakip ";
            string odeme = "";
            while (sqlDataReaders.Read())
            {
                odeme = sqlDataReaders["OrderId"].ToString();
            }
            sqlDataReaders.Close();
            System.Data.SqlClient.SqlCommand sqlCommands = new System.Data.SqlClient.SqlCommand(odemetakipdetay, sqlConnection);
            sqlCommands.Parameters.AddWithValue("odemetakip", odeme);
            System.Data.SqlClient.SqlDataReader sqlDataReader = sqlCommands.ExecuteReader();
            sqlDataReader.Close();
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sqlCommands);
            da.Fill(dt);
            sqlConnection.Close();
            string json = JsonConvert.SerializeObject(dt);
            var result = new DataSourceResult
            {
                Data = json,
                Total = 10,
                Errors = ""               
            };
            return Json(result.Data, JsonRequestBehavior.AllowGet);
Views 
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="content-header clearfix">
        <h1 class="pull-left">
            @T("Admin.Orders")
        </h1>
    </div>
    <div class="content">
        <div class="form-horizontal">
            <div class="panel-group">
                <div class="panel panel-default panel-search">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-5">
                                <div class="form-group">
                                    <div class="col-md-4">
                                       <b>Ödeme Takip Numarası</b>
                                    </div>
                                    <div class="col-md-4">
                                        <input type="text" id="search-product-name" placeholder="Ödeme Takip Numarası" autocomplete="off" class="form-control" />
                                        <span id="search-product-friendly-name"></span>
                                    </div>
                                    <div class="col-md-4">
                                        <span class="input-group-btn">
                                            <button type="submit" id="go-to-order-by-number" name="go-to-order-by-number" class="btn btn-info btn-flat">
                                               Sorgula
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-7 col-md-offset-5">
                                <button type="button" id="search-orders" class="btn btn-primary btn-search">
                                    <i class="fa fa-search"></i>
                                    @T("Admin.Common.Search")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div id="orders-grid"></div>
                        <script>
                            $(document).ready(function() {
                                $("#orders-grid").kendoGrid({
                                    dataSource: {
                                        type: "json",
                                        transport: {
                                            read: {
                                                url: "@Html.Raw(Url.Action("OdemeTakipGet", "Order"))",
                                                type: "POST",
                                                dataType: "json",
                                                data: additionalData
                                            }
                                        },
                                        schema: {
                                            data: "Data",
                                            total: "Total",
                                            errors: "Errors"
                                        },
                                        requestEnd: function (e) {
                                            if (e.type == "read") {
                                                var response = e.response;
                                                if (response) {
                                                    //store extra data
                                                    reportAggregates = e.response["Data"];
                                                }
                                            }
                                        },
                                        error: function(e) {
                                            display_kendoui_grid_error(e);
                                            // Cancel the changes
                                            this.cancelChanges();
                                        },
                                        pageSize: @(defaultGridPageSize),
                                        serverPaging: true,
                                        serverFiltering: true,
                                        serverSorting: true
                                    },
                                    pageable: {
                                        refresh: true,
                                        pageSizes: [@(gridPageSizes)]
                                    },
                                    editable: {
                                        confirmation: "@T("Admin.Common.DeleteConfirmation")",
                                        mode: "inline"
                                    },
                                    scrollable: false,
                                    dataBound: onDataBound,
                                    columns: [
                                        {
                                            field: "OrderId",
                                            title: "@T("Admin.Orders.Fields.Customer")",
                                            width: 250,
                                            template: '#=CustomerFullName# (#=CustomerEmail#)'
                                        },
                                        {
                                            field: "BankResponseContent",
                                            title: "@T("Admin.Orders.Fields.Store")",
                                            width: 100
                                        }, {
                                            field: "ShortErrorMessage",
                                            title: "@T("Admin.Orders.Fields.IsReconciliated")",
                                            width: 50,
                                            attributes: { style: "text-align:center" },
                                        }, {
                                            field: "CreatedOnUtc",
                                            title: "@T("Admin.Orders.Fields.CreatedOn")",
                                            width: 150,
                                            type: "date",
                                            format: "{0:G}"
                                        },
                                    ]
                                } );
                            });
                        </script>
                        <script type="text/javascript">
                            var selectedIds = [];
                            var reportAggregates = "";
                            $(document).ready(function () {
                                //search button
                                $('#search-orders').click(function () {
                                    //search
                                    var grid = $('#orders-grid').data('kendoGrid');
                                    grid.dataSource.page(1); //new search. Set page size to 1
                                    //grid.dataSource.read(); we already loaded the grid above using "page" function
                                    //clear selected checkboxes
                                    $('.checkboxGroups').attr('checked', false).change();
                                    selectedIds = [];
                                    return false;
                                });                      
                            });
                            function additionalData() {
                                var data = {
                                   @*StartDate: $('#@Html.FieldIdFor()').val(),
                                    EndDate: $('#@Html.FieldIdFor('BankResponseContent')').val(),
                                    OrderStatusIds: $('#@Html.FieldIdFor(model => model.OrderStatusIds)').val(),
                                    PaymentStatusIds: $('#@Html.FieldIdFor(model => model.PaymentStatusIds)').val(),*@
                                 
                                };
                                addAntiForgeryToken(data);
                                return data;
                            }
                            function onDataBound(e) {
                                $('#orders-grid input[type=checkbox][id!=mastercheckbox]').each(function () {
                                    var currentId = $(this).val();
                                    var checked = jQuery.inArray(currentId, selectedIds);
                                    //set checked based on if current checkbox's value is in selectedIds.
                                    $(this).attr('checked', checked > -1);
                                });
                                updateMasterCheckbox();
                                //update order totals summary
                                if (reportAggregates != "") {
                                    for (var key in reportAggregates) {
                                        $('#aggregator-profit-block').text(reportAggregates['aggregatorprofit']);
                                        $('#aggregator-shipping-block').text(reportAggregates['aggregatorshipping']);
                                        $('#aggregator-tax-block').text(reportAggregates['aggregatortax']);
                                        $('#aggregator-total-block').text(reportAggregates['aggregatortotal']);
                                    }
                                }
                            }
                            function updateMasterCheckbox() {
                                var numChkBoxes = $('#orders-grid input[type=checkbox][id!=mastercheckbox]').length;
                                var numChkBoxesChecked = $('#orders-grid input[type=checkbox][id!=mastercheckbox]:checked').length;
                                $('#mastercheckbox').attr('checked', numChkBoxes == numChkBoxesChecked && numChkBoxes > 0);
                            }
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
}