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

How AuotCompltedBox postbax and get the selected item id on server side

6 Answers 405 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 29 Jan 2014, 09:19 AM
Hi,
   I want to do when i selected AutoCompleteBox  item i want to do a postback and get the selected items id on server side.so provide solutions.
Thanks,
Rahul

6 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 31 Jan 2014, 04:28 PM
Hello Rahul,

Please use the RadAutoCompleteBox EntryAdded server-side event and enable by setting AutoPostBack property to "True"
//markup code
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ContactName" DataValueField="CustomerID" AutoPostBack="true" OnEntryAdded="RadAutoCompleteBox1_EntryAdded">
      </telerik:RadAutoCompleteBox>
        <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnString %>"
       ProviderName="System.Data.SqlClient" SelectCommand="SELECT [CustomerID], [ContactName] FROM [Customers] ORDER By ContactName">
   </asp:SqlDataSource>

//code behind
protected void RadAutoCompleteBox1_EntryAdded(object sender, AutoCompleteEntryEventArgs e)
   {
       AutoCompleteBoxEntry entry = e.Entry;
       //you can access the entry text
       String entryText = entry.Text;
   }


Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 25 Jun 2020, 05:29 AM

And how can I populate a List of strings (items keys) from all the items selected by the user in the RadAutoCompleteBox in a WebForms page?

L.

0
Peter Milchev
Telerik team
answered on 29 Jun 2020, 08:58 AM

Hello L.,

The "selected items" are available only in the Entries collection of the AutoCompleteBox. 

Once you get the entries, you can use any method to collect their texts or values and create any collection out of them. 

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 29 Jun 2020, 01:25 PM

Do you have an example Peter? 

Luigi

0
Peter Milchev
Telerik team
answered on 01 Jul 2020, 10:37 AM

Hello Luigi,

Here is a simple example iterating the Entries collection and getting the Text of the entries:

protected void RadButton1_Click(object sender, EventArgs e)
{
    var texts = new List<string>();
    foreach (AutoCompleteBoxEntry entry in RadAutoCompleteBox1.Entries)
    {
        texts.Add(entry.Text);
    }
}

Another option is demonstrated here:

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ciupaz
Top achievements
Rank 2
Veteran
answered on 01 Jul 2020, 12:24 PM

Thank you Peter, this is Ok.

Luigi

Tags
AutoCompleteBox
Asked by
Rahul
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Ciupaz
Top achievements
Rank 2
Veteran
Peter Milchev
Telerik team
Share this question
or