ASP.NET ListItem Selected 屬性
定義和用法
Selected 屬性用於設置或返回是否默認地選定ListItem。
如果該屬性被設置為TRUE,則ListItem 被默認地選定,否則為FALSE。 默認是FALSE。
語法
<asp:ListItem Selected="True|False" runat="server" />
實例
下面的實例設置了ListBox 控件中被選定的ListItem:
<form runat="server">
<asp:ListBox runat="server">
<asp:ListItem Text="Item1" Selected="True"/>
<asp:ListItem Text="Item2" />
</asp:ListBox>
</form>
<asp:ListBox runat="server">
<asp:ListItem Text="Item1" Selected="True"/>
<asp:ListItem Text="Item2" />
</asp:ListBox>
</form>
演示實例»
ListItem控件