Monday, June 20, 2016

Add stuff to ASPxComboBox controls!

This will show the blank entry as the default:

<dx:ASPxComboBox runat="server" ID="Whatever">
   <Items>
      <dx:ListEditItem Text="" />
      <dx:ListEditItem Text="Foo" Value="Bar" />
   </Items>
</dx:ASPxComboBox>

 
 

The use of Selected here changes things and makes the Foo value the defaut:

<dx:ASPxComboBox runat="server" ID="Whatever">
   <Items>
      <dx:ListEditItem Text="" />
      <dx:ListEditItem Text="Foo" Value="Bar" Selected />
   </Items>
</dx:ASPxComboBox>

 
 

Use a ASPxListBox (multiselect) instead of a ASPxComboBox (dropdown list) is you need multiple line items showing at once. Shove in a third item on the C# side and make it selected like so:

var whatever = (ASPxComboBox)e.Item.FindControl("Whatever");
var item = new ListEditItem("Baz", "Qux");
whatever.Items.Add(item);
whatever.SelectedIndex = 2;

 
 

More shit:

No comments:

Post a Comment