New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

WCF Web Service

  • Politics
  • Sports
  • Events

This example demonstrates how to populate RadTreeView from WCF Web Service. You need to point to an existing web service and method:

<telerik:RadTreeView runat="server" ID="RadTreeView2" 
	DataSourceID="LinqDataSource1"
	DataTextField="Text" DataValueField="id" >
	<WebServiceSettings Path="TreeViewWcfService.svc" Method="LoadData" />
	<DataBindings>
		<telerik:RadTreeNodeBinding Depth="0" ExpandMode="WebService" />
	</DataBindings>
</telerik:RadTreeView>

The root nodes are populated from a EntityFramework datasource:

Check the source code of the web service for the implementation of the LoadData method.

Expand a node to populate its children on demand.
  • DefaultCS.aspx
<%@ Page Language="C#"  Inherits="Telerik.QuickStart.QsfPage" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-thin">
        <telerik:RadTreeView RenderMode="Lightweight" runat="server" ID="RadTreeView2" DataSourceID="EntityDataSource1" 
            DataTextField="Text" DataValueField="id" LoadingStatusPosition="AfterNodeText">
            <WebServiceSettings Path="WcfService.svc" Method="LoadData">
            </WebServiceSettings>
            <DataBindings>
                <telerik:RadTreeNodeBinding Depth="0" ExpandMode="WebService"></telerik:RadTreeNodeBinding>
            </DataBindings>
        </telerik:RadTreeView>
    </div>
    <asp:EntityDataSource runat="server" ID="EntityDataSource1" ConnectionString="name=TelerikReadOnlyEntities" 
        DefaultContainerName="TelerikReadOnlyEntities" EntitySetName="Links" Where="it.[parentId] IS NULL">
    </asp:EntityDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance