RadAutoCompleteBox Set Value programtically.

1 Answer 370 Views
AutoCompleteBox
Roger
Top achievements
Rank 2
Iron
Iron
Iron
Roger asked on 22 Jul 2021, 03:12 PM

I have a RadAutoCompleteBox.  Many times I fill it dynamically with a SQL Query.

But on an occasion, I need to fill it with "N/A" and Select "N/A" Automatically.

Is there a way to do this?

 

Thanks,

Rog

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 27 Jul 2021, 08:21 AM

Hi Roger,

You can add entries on the Client (Recommended)

function OnClientClicked(sender, args) {
    var autoCompleteBox = $find("<%= RadAutoCompleteBox1.ClientID %>");

    var entry = new Telerik.Web.UI.AutoCompleteBoxEntry(); // create the entry
    entry.set_text("N/A"); // set the text of the Entry
    autoCompleteBox.get_entries().add(entry); // Add the Entry to the AutoCompleteBox entry collection
}

 

You can also add on the server

protected void RadButton1_Click(object sender, EventArgs e)
{
    RadAutoCompleteBox1.Entries.Add(new AutoCompleteBoxEntry() { Text = "N/A" });
}

 

Regards,
Attila Antal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Roger
Top achievements
Rank 2
Iron
Iron
Iron
commented on 29 Jul 2021, 03:57 PM

Yes this ADDS the entry, but then I want it selected and that is what I am having an issue doing.
Attila Antal
Telerik team
commented on 30 Jul 2021, 11:44 AM

There is no Selection functionality for the AutoCompleteBox. Entries added to it are the equivalent of having Selected Items in a ListBox.

How did you imagine selecting the entries? Something like focusing them?

Tags
AutoCompleteBox
Asked by
Roger
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Attila Antal
Telerik team
Share this question
or