New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Data Binding Overview

RadTagCloud supports binding to all ASP.NET 2.0/3.5 DataSource components, including:

  • AccessDataSource

  • SqlDataSource

  • XmlDataSource

  • ObjectDataSource

  • SiteMapDataSource

  • LinqDataSource

  • EntityDataSource

To bind to a DataSource component, you need to set the following properties:

  • DataSourceID property of the tagCloud to the ID of the DataSource component

  • DataTextField property to the field of the DataSource component that provides the text content.

  • DataNavigteUrlField property to the field of the DataSource component that provides the URL (NavigateUrl) content.

  • DataWeightField property to the field of the DataSource component that provides the weight content.

Here is an example that shows how to bind the tagCloud to an ObjectDataSource. In asimilar way the control can be bound to any of the above mentioned DataSource components.

ASP.NET
<div>
	<telerik:RadTagCloud RenderMode="Lightweight" ID="RadTagCloud2" runat="server" Width="400px" MaxFontSize="50px"
		Sorting="AlphabeticAsc" DataSourceID="ObjectDataSource1" DataTextField="Text"
		DataWeightField="Weight" DataNavigateUrlField="NavigateUrl">
	</telerik:RadTagCloud>
	<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSiteData"
		TypeName="TagCloudDataItem"></asp:ObjectDataSource>
</div>
C#
/// <summary>
/// This class is only for demonstration purposes. The class used in this example resides in the App_Code folder
/// </summary>
public class TagCloudDataItem
{
	private string _text;
	private string _navigateUrl;
	private double _weight;
	public string Text
	{
		get { return _text; }
		set { _text = value; }
	}

	public string NavigateUrl
	{
		get { return _navigateUrl; }
		set { _navigateUrl = value; }
	}
	public double Weight
	{
		get { return _weight; }
		set { _weight = value; }
	}
	public TagCloudDataItem(string text, string navigateUrl, double weight)
	{
		_text = text;
		_navigateUrl = navigateUrl;
		_weight = weight;
	}
	public static List<TagCloudDataItem> GetSiteData()
	{
		List<TagCloudDataItem> siteData = new List<TagCloudDataItem>();
		siteData.Add(new TagCloudDataItem("Russia", "https://en.wikipedia.org/wiki/Russia", 141.9));
		siteData.Add(new TagCloudDataItem("Nigeria", "https://en.wikipedia.org/wiki/Nigeria", 154.7));
		siteData.Add(new TagCloudDataItem("Saudi Arabia", "https://en.wikipedia.org/wiki/Saudi_Arabia", 28.6));
		siteData.Add(new TagCloudDataItem("Canada", "https://en.wikipedia.org/wiki/Canada", 34.1));
		siteData.Add(new TagCloudDataItem("USA", "https://en.wikipedia.org/wiki/USA", 309.4));
		siteData.Add(new TagCloudDataItem("Sweden", "https://en.wikipedia.org/wiki/Sweden", 9.3));
		siteData.Add(new TagCloudDataItem("Germany", "https://en.wikipedia.org/wiki/Germany", 81.7));
		siteData.Add(new TagCloudDataItem("Turkey", "https://en.wikipedia.org/wiki/Turkey", 72.5));
		siteData.Add(new TagCloudDataItem("Japan", "https://en.wikipedia.org/wiki/Japan", 127.3));
		siteData.Add(new TagCloudDataItem("France", "https://en.wikipedia.org/wiki/France", 65.4));
		return siteData;
	}
}
Not finding the help you need?
Contact Support