kendo grid from json asp.net not work

1 posts, 0 answers
  1. Mohamed
    Mohamed avatar
    1 posts
    Member since:
    Jun 2014

    Posted 30 Jun 2014 Link to this post

    This is my first time i follow kendo grid .I try to bind kendo grid using json but i always return nothing .page code is

    <link href="Content/kendo/2014.1.318/kendo.common.min.css" rel="stylesheet" />
    <link href="Content/kendo/2014.1.318/kendo.default.min.css" rel="stylesheet" />
    <script src="Scripts/kendo/2014.1.318/jquery.min.js"></script>
    <script src="Scripts/kendo/2014.1.318/kendo.web.min.js"></script>


    <script>
    $(document).ready(function () {
    $("#grid").kendoGrid({
    dataSource: {
    type: "json",
    transport: {
    read: function (options) {
    $.ajax({
    url: "kendogrid.aspx/GetUserList",
    dataType: "json",
    success: function (result) {
    options.success(result);

    },
    pageSize: 10,
    schema: {
    data: function (response) {
    return response.d;
    }
    }
    });
    },
    batch: true,
    schema: {
    type: 'json',
    model: {
    id: "U_ID",
    fields: {
    U_ID: { type: "string" },
    U_UserName: { type: "string" },
    U_FullName: { type: "string" }
    }
    }
    },
    pageSize: 10
    },
    height: 430,
    filterable: true,
    groupable: true,
    sortable: true,
    pageable: true,
    columns: [{
    field: "U_ID",
    title: "U_ID",
    width: 140
    }, {
    field: "U_UserName",
    title: "U_UserName",
    width: 190
    }, {
    field: "U_FullName",
    title: "U_FullName"
    }]
    }
    });
    });


    </script>

    </head>
    <body>
    <form id="form1" runat="server">


    <div id="grid">
    </div>


    </form>and this my code behind [WebMethod]
    public static string GetUserList()
    {
    string strConnString =ConfigurationManager.ConnectionStrings["books_alaaConnectionString"].ConnectionString;

    using (SqlConnection con=new SqlConnection(strConnString))
    {
    using (SqlCommand cmd=new SqlCommand("Select * from Tbl_Users"))
    {
    using (SqlDataAdapter sda = new SqlDataAdapter())
    {
    DataTable dt=new DataTable();
    cmd.CommandType = CommandType.Text;
    cmd.Connection = con;
    sda.SelectCommand = cmd;
    sda.Fill(dt);

    var returnJSON = (from p in dt.AsEnumerable()
    select new
    {
    ClientUID = p.Field<string>("U_ID")
    }).ToList();
    var serializer = new JavaScriptSerializer();
    string json = serializer.Serialize(returnJSON);
    return json;
    }
    }
    }
    }



    }its always return nothing where is the problem and how can i solve it??
Back to Top