這三個控件都有一個Items集合,可以用 RepeatLayout 和 RepeatDirection 屬性來控制列表的呈現(xiàn)形式。如果 RepeatLayout 的值為 Table,那么將在表中呈現(xiàn)列表。如果設置成 Flow,那么將在沒有任何表結構的情況下呈現(xiàn)列表。默認情況下,RepeatDirection 的值為 Vertical。將此屬性設置成 Horizontal 將會使列表水平呈現(xiàn)。
RadioButtonList:控件提供已選中一個選項的單項選擇列表(數(shù)據(jù)源單選)。與其他列表控件相似,RadioButtonList 有一個 Items 集合,其成員與列表中的每個項目相對應。
DropDownList:下拉列表選擇,對于有些形式的輸入,用戶必須從適用選項列表中選擇一個選項(下拉唯一選擇)。
CheckBoxList:多選列表,將數(shù)據(jù)源以橫向或縱向方式呈現(xiàn)給用戶,用戶可以進行多個item的選擇。
由于這三個控件是服務器端控件,需要在客戶端進行解析,下面有三個控件的服務器端、客戶端例子
服務器端
代碼如下:
<asp:RadioButtonList ID="RadioButtonList1" RepeatDirection="Horizontal" RepeatLayout="Flow"
runat="server">
<asp:ListItem Value="0">單選一</asp:ListItem>
<asp:ListItem Value="1">單選二</asp:ListItem>
<asp:ListItem Value="2">單選三</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:CheckBoxList ID="CheckBoxList1" RepeatDirection="Horizontal" RepeatLayout="Flow"
runat="server">
<asp:ListItem Value="0">多選一</asp:ListItem>
<asp:ListItem Value="1">多選二</asp:ListItem>
<asp:ListItem Value="2">多選三</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:DropDownList ID="DropDownList1" RepeatDirection="Horizontal" RepeatLayout="Flow"
runat="server">
<asp:ListItem Value="0">下拉選擇一</asp:ListItem>
<asp:ListItem Value="1">下拉選擇二</asp:ListItem>
<asp:ListItem Value="2">下拉選擇三</asp:ListItem>
新聞熱點
疑難解答
圖片精選