Binding to Array, or ArrayList
Both Array and ArrayList could make an excelent data source for RadAutoCompleteBox. The following example demonstrates a valid usage of both data sourses, defining them at runtime.
Binding to Array and ArrayList at runtime
The declarations of RadAutoCompleteBox objects include no DataSourceID property or Items section:
<telerik:RadAutoCompleteBox RenderMode="Lightweight" ID="RadAutoCompleteBox1" runat="server">
</telerik:RadAutoCompleteBox>
<telerik:RadAutoCompleteBox RenderMode="Lightweight" ID="RadAutoCompleteBox2" runat="server">
</telerik:RadAutoCompleteBox>
In the Page_Load event handler create the Array and ArrayList and bind them to the RadAutoCompleteBox objects. The DataBind method must be called after setting the DataSource property.
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsCallback)
{
BindToArrayList(RadAutoCompleteBox1);
BindToArray(RadAutoCompleteBox2);
}
}
private void BindToArray(RadAutoCompleteBox autoCompleteBox)
{
string[] itemsList = { "One", "Two", "Three" };
autoCompleteBox.DataSource = itemsList;
}
private void BindToArrayList(RadAutoCompleteBox autoCompleteBox)
{
ArrayList itemsList = new ArrayList();
itemsList.Add("One");
itemsList.Add("Two");
itemsList.Add("Three");
autoCompleteBox.DataSource = itemsList;
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Page.IsCallback Then
BindToArrayList(RadAutoCompleteBox1)
BindToArray(RadAutoCompleteBox2)
End If
End Sub 'Page_Load
Private Sub BindToArray(ByVal autoCompleteBox As RadAutoCompleteBox)
Dim itemsList As String() = {"One", "Two", "Three"}
autoCompleteBox.DataSource = itemsList
End Sub 'BindToArray
Private Sub BindToArrayList(ByVal autoCompleteBox As RadAutoCompleteBox)
Dim itemsList As New ArrayList()
itemsList.Add("One")
itemsList.Add("Two")
itemsList.Add("Three")
autoCompleteBox.DataSource = itemsList
End Sub 'BindToArrayList