$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ComboBox Elements in ASP.NET
Home > How to > ComboBox Elements

The asp.net ComboBox control enables users to modify and customize the items with a list of available properties. And in this article, we will show you how to use these properties for changing the item settings in ASP.NET AJAX.

ComboBox Item Properties

Here we list the properties that the web ComboBox Control has offered and briefly illustrate the functions each property has owned.
  • Text: it means the text string that users can view in the drop-down list.
  • ToolTip: it controls the text string that appears when the mouse is over an item in the drop-down list.
  • Value: this property is a unique identifier for the item, which is used to define the value of SelectedValue property when an item is selected.
  • Selected: it is an indicator of whether the item is selected or not. And this property only allows users to select one item at a time. Therefore, if you set the Selected property of one item to true, then the Selected property of other items will be defined to false automatically. And if there is no item being selected, the Selected property of all items will be false.
  • Enabled: if you set this property to true, then users will be allowed to select the item from the drop-down list.
  • ImageUrl: you can use this property to define which image will be showed on the left of the item Text.
The programming example below is offered to guide you how to use above combobox item properties in aspx web page.
<kettic:PerComboBox runat="server" ID="PerComboBox1">
<kettic:PerComboBoxItem runat="server" Text="ASP.NET" Value="ASP.NET" ToolTip="ASP.NET" Selected="true" />
<kettic:PerComboBoxItem runat="server" Text="WPF" Value="WPF" />
<kettic:PerComboBoxItem runat="server" Text="WCF" Value="WCF" />
<kettic:PerComboBoxItem runat="server" Text="Java" Value="Java" />
<kettic:PerComboBoxItem runat="server" Text="J2EE" Value="J2EE" />
<kettic:PerComboBoxItem runat="server" Text="JavaScript" Value="JavaScript" />
<kettic:PerComboBoxItem runat="server" Text="JQuery" Value="JQuery" />
<kettic:PerComboBoxItem runat="server" Text="ActionScript"
Value="ActionScript" />
<kettic:PerComboBoxItem runat="server" Text="OpenGL" Value="OpenGL" />
<kettic:PerComboBoxItem runat="server" Text="PHP" Value="PHP" />
Following image shows the result of above ASP.NET programming example.

Default Item of ComboBox

The Default Item property is mainly used for custom validation scenarios. The item that you set using the Default Item will be displayed as the first item in the drop-down list. Note: for easier validation, the value of the asp.net ComboBox DOM object will return default item's value once the default item is selected.
Following sample code is used to show users how to use the Default Item property in aspx web page.
<kettic:PerComboBox runat="server" ID="PerComboBox2" Skin="Silk">
<DefaultItem runat="server" Text="Please select item" Value="-1" />
<kettic:PerComboBoxItem runat="server" Text="1" Value="1" />
<kettic:PerComboBoxItem runat="server" Text="2" Value="2" />
<kettic:PerComboBoxItem runat="server" Text="3" Value="3" />
<kettic:PerComboBoxItem runat="server" Text="4" Value="4" />
<kettic:PerComboBoxItem runat="server" Text="5" Value="5" />
<kettic:PerComboBoxItem runat="server" Text="6" Value="6" />
<kettic:PerComboBoxItem runat="server" Text="7" Value="7" />
<kettic:PerComboBoxItem runat="server" Text="8" Value="8" />
<kettic:PerComboBoxItem runat="server" Text="9" Value="9" />
<kettic:PerComboBoxItem runat="server" Text="10" Value="10" />

Similarly, to help you understand the function of the Default Item property in a more direct way, we here present an image which displays the output of above programming example.

Related ComboBox Item Tutorial

If you want to set the properties of combobox items using Visual C# .NET programming code, please visit this ASP.NET AJAX ComboBox Item Settings Using C# Code.