This is a migrated thread and some comments may be shown as answers.

How to preselect an item

2 Answers 78 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Gopi
Top achievements
Rank 1
Gopi asked on 30 Sep 2019, 08:19 PM

Hello, I am using code like so to populate a RadAutoCompleteBox in ASP.NET:

RadAutoCompleteBoxNextID.Entries.Add(new AutoCompleteBoxEntry { Text = "ABC" });

RadAutoCompleteBoxNextID.Entries.Add(new AutoCompleteBoxEntry { Text = "DEF" });

RadAutoCompleteBoxNextID.Entries.Add(new AutoCompleteBoxEntry { Text = "GHI" });

 

How do I display a default value of "ABC" --  which is the first item in the Entries list -- in the AutoCompleteBox?

2 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 03 Oct 2019, 08:29 AM

Hello Gopi,

The Entries collection of the AutoCompleteBox is used to add the pre-selected tokens for the control. 

Using the following code will set the three strings as data source of the control and will pre-select "ABC" as shown below:

<telerik:RadAutoCompleteBox RenderMode="Lightweight" ID="RadAutoCompleteBox1" runat="server" Width="400" DropDownHeight="150"
    EmptyMessage="Select Continents">
</telerik:RadAutoCompleteBox>

protected void Page_Load(object sender, EventArgs e)
{
    RadAutoCompleteBox1.Entries.Add(new AutoCompleteBoxEntry { Text = "ABC" });
    RadAutoCompleteBox1.DataSource = new List<string>() { "ABC", "DEF", "GHI" };
}

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Gopi
Top achievements
Rank 1
answered on 12 Nov 2019, 06:24 PM
Great, thanks Peter!
Tags
AutoCompleteBox
Asked by
Gopi
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Gopi
Top achievements
Rank 1
Share this question
or