3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 30 Jul 2013, 01:06 PM
Hi JC,
As far as I know RadAutoCompleteBox does not support preselecting items, coming from its data source, out-of-the-box. But, you still can manipulate the data source itself so you will be able to have preselected entries. Please have a look at the following code which uses an ASP SQLDataSource.
ASPX:
C#:
Thanks,
Shinu.
As far as I know RadAutoCompleteBox does not support preselecting items, coming from its data source, out-of-the-box. But, you still can manipulate the data source itself so you will be able to have preselected entries. Please have a look at the following code which uses an ASP SQLDataSource.
ASPX:
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox2" runat="server" Width="200px" DropDownWidth="200px" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="ID" OnDataBound="RadAutoCompleteBox2_DataBound"></telerik:RadAutoCompleteBox><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>" SelectCommand="SELECT [ID], [CountryID], [Name] FROM [Cities]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>C#:
protected void Page_Load(object sender, EventArgs e){ if (!Page.IsPostBack) { DataSourceSelectArguments args = new DataSourceSelectArguments(); DataView view = (DataView)SqlDataSource1.Select(args); DataTable table = view.ToTable(); string ID = "", countryID = "", name = ""; for (int i = 0; i < table.Rows.Count; i++) { ID = table.Rows[i].ItemArray[0].ToString(); countryID = table.Rows[i].ItemArray[1].ToString(); name = table.Rows[i].ItemArray[2].ToString(); if (!string.IsNullOrEmpty(ID) && ID == "1") { if (!string.IsNullOrEmpty(name)) { RadAutoCompleteBox2.Entries.Add(new AutoCompleteBoxEntry(name, ID)); } } } }}Thanks,
Shinu.
0
Kamelia
Top achievements
Rank 1
answered on 12 Nov 2014, 06:49 AM
Hi, Is it possible to preselect items in a radautocompletebox in windows form ???
I have some items which I want to have them in my radautocompletebox , so I can remove or add items in it . AND I need it to show me the items I had entered before.
thank you in advance
I have some items which I want to have them in my radautocompletebox , so I can remove or add items in it . AND I need it to show me the items I had entered before.
thank you in advance
0
Hello,
In order to predefine some entries for the RadAutoCompleteBox, you need to use the Entries collection of the control. Please consider the following approach:
Regards,
Nencho
Telerik
In order to predefine some entries for the RadAutoCompleteBox, you need to use the Entries collection of the control. Please consider the following approach:
RadAutoCompleteBox1.Entries.Add(new AutoCompleteBoxEntry("Text", "Value"));Regards,
Nencho
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
