ASP.NET DropDownList 控件
定義和用法
DropDownList 控件用于創建下拉列表。
DropDownList 控件中的每個可選項都是由 ListItem 元素定義的!
提示:該控件支持數據綁定!
屬性
屬性 | 描述 | .NET |
---|---|---|
SelectedIndex | 可選項的索引號 | 1.0 |
OnSelectedIndexChanged | 當被選項目的 index 被更改時被執行的函數的名稱。 | 1.0 |
runat | 規定該控件是服務器控件。必須設置為 "server"。 | 1.0 |
ListControl 標準屬性
AppendDataBoundItems, AutoPostBack, CausesValidation, DataTextField, DataTextFormatString, DataValueField, Items, runat, SelectedIndex, SelectedItem, SelectedValue, TagKey, Text, ValidationGroup, OnSelectedIndexChanged
ListControl 控件包括列表控件的所有基本功能。繼承自此控件的控件包括:CheckBoxList, DropDownList, ListBox 以及 RadioButtonList 控件。
如需完整描述,請訪問 ListControl 標準屬性。
Web 控件標準屬性
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, SkinID, Style, TabIndex, ToolTip, Width
如需完整描述,請訪問 Web 控件標準屬性。
控件標準屬性
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Visible
如需完整描述,請訪問控件標準屬性。
實例
- DropdownList
- 在本例中,我們在 .aspx 文件中聲明了一個 DropDownList 控件。然后創建了一個事件句柄,在 Click 事件發生時在 Label 控件中顯示文本和被選項目。