Hi.
I have a combobox which load items on demand. Everything works great but I want the for loaded items to automatically select the first item so the user always have something selected. I have tried several different approaches but nothing seems to work. I need it to not only work in code but also visually look like it has the first item selected.
The code is:
The OnItemsRequested event handler is
Thanks.
Jose
I have a combobox which load items on demand. Everything works great but I want the for loaded items to automatically select the first item so the user always have something selected. I have tried several different approaches but nothing seems to work. I need it to not only work in code but also visually look like it has the first item selected.
The code is:
| <telerik:RadComboBox ID="rcbDeparture" runat="server" Skin="Vista" |
| DropDownWidth="350px" MaxHeight="300px" |
| EnableLoadOnDemand="True" |
| EmptyMessage="Choose City" |
| OnItemsRequested="rcbDeparture_ItemsRequested" > |
| <ExpandAnimation Type="None" /> |
| <CollapseAnimation Type="None" /> |
| </telerik:RadComboBox> |
The OnItemsRequested event handler is
| protected void rcbDeparture_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) |
| { |
| var combo = (RadComboBox)o; |
| var locations = MyService.AllDepartures(e.Text); |
| combo.Items.Clear(); |
| if (locations.Count > 0) |
| { |
| bool found = false; |
| foreach (var l in locations) |
| { |
| var item = new RadComboBoxItem(l.Name, l.ID.ToString()); |
| if (!found) |
| { |
| item.Selected = true; |
| found = true; |
| } |
| combo.Items.Add(item); |
| } |
| combo.Items[0].Selected = true; |
| } |
| } |
Thanks.
Jose