单选按钮列表和复选框列表

单选按钮列表显示了互斥选项的列表。复选框列表显示独立选项列表。这些控件包含一组 ListItem 对象,可以通过控件的 Items 属性引用它们。

单选按钮列表的基本语法:

<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" 
   OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList>

复选框列表的基本语法:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True" 
   OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">
</asp:CheckBoxList>

复选框和单选按钮列表的常用属性:

属性 描述
RepeatLayout 此属性指定在呈现列表时格式化列表时要使用的表标记还是正常的 html 流。默认为 Table。
RepeatDirection 它指定了重复控件的方向。可用值为水平垂直。默认为垂直。
RepeatColumns 它指定重复控件时要使用的列数; 默认值为 0。