RadGrid Data Bind at client side using PageMethod

4 posts, 0 answers
  1. Noha
    Noha avatar
    30 posts
    Member since:
    Sep 2010

    Posted 08 May 2013 Link to this post

    Dear All

    I created a page method that return the result data source in json string format to bind the RadGrid:

    public static string GetRows(int from, int len)
        DataTable dt =  MyEntity_BL.GetData();
        //convert DataTable into Json string
        System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
        List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
        Dictionary<string, object> row = null;
        foreach (DataRow dr in dt.Rows)
            row = new Dictionary<string, object>();
            foreach (DataColumn col in dt.Columns)
                row.Add(col.ColumnName, dr[col]);
        return serializer.Serialize(rows);

    and then i call the page method at client side at user button click:

    function btnShowClientClick(clickedButton) {
        PageMethods.GetRows(0, 0, Succsess);
    function Succsess(result) {
        var masterTable = $find("<%= grd.ClientID %>").get_masterTableView();

    The problem is that there no action done on the RadGrid ??
    It doesn't bind any data!

    Is there something miss ?

  2. Pavlina
    Pavlina avatar
    6184 posts

    Posted 13 May 2013 Link to this post

    Hi Noha,

    When binding RadGrid on the client, the data must have a valid JSON syntax, in order to be properly parsed. The data itself may be coming from a WebService/PageMethod, or declared statically. More information you could find in the following online documentation article:

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. luc bonenfant
    luc bonenfant avatar
    53 posts
    Member since:
    Sep 2007

    Posted 16 Sep 2015 Link to this post

    I had the same behavior and, client side, i needed to transform string to JSON by :

        var $ = $telerik.$;
        result = $.parseJSON(result); 

    I don't understand because ajax datatype ​should be JSON... may be string is particular

  4. Konstantin Dikov
    Konstantin Dikov avatar
    2425 posts

    Posted 22 Sep 2015 Link to this post

    Hello Luc,

    I would suggest that you take a look at the following help article and the "dataType" part in particular, where you will find detailed information about the returned type of the request:
    Hope this helps.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top