This is a migrated thread and some comments may be shown as answers.

RadListView (Client-side Data Binding)

3 Answers 78 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 09 Dec 2012, 10:56 PM
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?

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 12 Dec 2012, 03:25 PM
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.
0
Mark
Top achievements
Rank 1
answered on 13 Dec 2012, 03:41 AM
Unfortunately that didn't work.  Any other ideas?
0
Tsvetoslav
Telerik team
answered on 13 Dec 2012, 02:58 PM
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.
Tags
ListView
Asked by
Mark
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Mark
Top achievements
Rank 1
Share this question
or