New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Binding to Array or ArrayList
RadTagCloud can be bound to an Array or ArrayList. This example shows how to bind RadTagCloud to an Array and ArrayList at runtime
The declaration of the RadTagCloud objects includes no DataSourceID property or <Items>
section:
ASP.NET
<telerik:RadTagCloud RenderMode="Lightweight" ID="RadTagCloud1" runat="server" Width="400px">
</telerik:RadTagCloud>
<telerik:RadTagCloud RenderMode="Lightweight" ID="RadTagCloud2" runat="server" Width="400px">
</telerik:RadTagCloud>
In the Page_Load event handler, create the Array and the ArrayList, and bind them to the RadTagCloud objects. You must call the DataBind method after setting the DataSource property.
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindToArrayList(RadTagCloud1);
BindToArray(RadTagCloud2);
}
}
private void BindToArray(RadTagCloud cloud)
{
string[] itemsList = { "Energy", "Oil", "Technology" };
cloud.DataSource = itemsList; cloud.DataBind();
}
private void BindToArrayList(RadTagCloud cloud)
{
ArrayList itemsList = new ArrayList();
itemsList.Add("One");
itemsList.Add("Two");
itemsList.Add("Three");
cloud.DataSource = itemsList;
cloud.DataBind();
}