New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Binding to Array or ArrayList
Both Array and ArrayList could be used as a Data Source by RadSearchBox. The following example demonstrates a valid use of both Data Sources, defining them at runtime.
Binding to Array and ArrayList at runtime
The declarations of the RadSearchBox objects does not include DataSourceID property:
ASPNET
<telerik:RadSearchBox RenderMode="Lightweight" runat="server" ID="RadSearchBox1" >
<DropDownSettings Height="400" Width="300" />
</telerik:RadSearchBox>
<telerik:RadSearchBox RenderMode="Lightweight" runat="server" ID="RadSearchBox2" >
<DropDownSettings Height="400" Width="300" />
</telerik:RadSearchBox>
One can use the Page_Load event handler to create the Array and ArrayList by setting the DataSource property of RadSearchBox accordingly.
C#
protected void Page_Load(object sender, EventArgs e)
{
BindToArrayList(RadSearchBox1);
BindToArray(RadSearchBox2);
}
private void BindToArray(RadSearchBox searchBox)
{
string[] itemsList = { "One", "Two", "Three" };
searchBox.DataSource = itemsList;
}
private void BindToArrayList(RadSearchBox searchBox)
{
ArrayList itemsList = new ArrayList();
itemsList.Add("One");
itemsList.Add("Two");
itemsList.Add("Three");
searchBox.DataSource = itemsList;
}