RadListView (Client-side Data Binding)

4 posts, 0 answers
  1. Mark
    Mark  avatar
    14 posts
    Member since:
    Aug 2007

    Posted 09 Dec 2012 Link to this post

    I am trying to get client-side data binding from a web service working for RadListView.  I am not getting any errors, but it doesn't seem to be binding.  I am using Newtonsoft JSON converter to generate the JSON response.

    <telerik:RadListView ID="lvWall" runat="server" AllowPaging="false">
        <ClientSettings>
            <DataBinding ItemPlaceHolderID="itemPlaceholder">
                <LayoutTemplate>
                    <ul id="itemPlaceholder"></ul>
                </LayoutTemplate>
                <ItemTemplate>
                    <li>#= WallText #</li>
                </ItemTemplate>
                <DataService Location="~/Engine.asmx" DataPath="Wall" />
            </DataBinding>
        </ClientSettings>
    </telerik:RadListView>

    Here's the web service method:

    [WebMethod]
    public string Wall()
    {
    DataSet ds = new DataSet();
                 
    try
    {
    SqlCommand comm = new SqlCommand("xbCircled_Wall", conn);
    comm.CommandType = CommandType.StoredProcedure;
    comm.Parameters.Add(new SqlParameter("@userID", 7));
    comm.Parameters.Add(new SqlParameter("@profileID", 9));
     
    SqlDataAdapter adapter = new SqlDataAdapter(comm);
    conn.Open();
    adapter.Fill(ds);
    }
    catch (Exception ex)
    {
    //throw new ServiceException("Error desription here", ex);
    }
    finally
    {
    conn.Close();
    }

    return JsonConvert.SerializeObject(ds);
    }

    Here is the JSON response that I am getting:
    {"d":"{\"Table\":[{\"WallID\":685,\"comments\":0,\"imageUrl\":\"http://www.bCircled.com/Assets/Uploaded-Photos/5b63d780-b01c-429b-9178-9efe4a4d8b84.jpg\",\"FromUserID\":9,\"FromFullName\":\"Jon Collins\",\"ToUserID\":9,\"ToFullName\":null,\"WallText\":\"A post to my own wall (status update) by Jon\",\"datePosted\":\"12 days ago\",\"actualDate\":\"2012-11-27T18:09:07.723\"}]}"}

    Why is the binding not working?  Something simple I've missed?
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 12 Dec 2012 Link to this post

    Hello Mark,

    Try adding the following setting for the list view's ClientSettings.DataBinding.DataService property collection:

    DataPropertyName = "Table"

    Hope it helps.

    Regards, Tsvetoslav
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark  avatar
    14 posts
    Member since:
    Aug 2007

    Posted 12 Dec 2012 Link to this post

    Unfortunately that didn't work.  Any other ideas?
  5. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 13 Dec 2012 Link to this post

    Hello Mark,

    The best approach both in terms of good programming practices and of getting the list view to display the data is to fill the data from the sql command into a collection of custom objects of yours. Then return a list of those custom objects from the web service method. It seems that newtonsonft converter is not getting any RadListView-understandable json all the more as you are trying to convert a whole dataset.

    Kind regards,
    Tsvetoslav
    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.
Back to Top