« 上一篇下一篇 »

RadioButtonList控件简介

RadioButtonList控件是一组  RadioButton控件。当需要多个选项中做出单一选项时,或需要在程序中改变单选按钮的个数时,使用  RadioButtonList控件要比使用多个单个  RadioButton控件方便的多。那么什么是  RadioButtonList控件呢?

       1.语法格式
 
       RadioButtonList控件的语法格式如下:

       <asp:   RadioButtonList属性设置> </asp:   RadioButtonList>

       或<asp:   RadioButtonList属性设置/>

       2.属性

       除了  RadioButton与WEB服务器控件共有的属性外,  RadioButton-List还有以下一些属性:

     (1).DataSource属性:用于指定填充  RadioButtonList控件的数据源,通常为数据表。

     (2).DataTextField属性:用于指定DataSource中的一个字段,该字段的值对应于列表项的text属性。

     (3).DataValueField属性:用于指定DataSource中的一个字段,该字段的值对应于列表的value属性。

     (4)Items属性:表示列表中各个选项的集合。

     (5).RepeatColumns属性:指定在  RadioButtonList控件显示项的列数。默认值为0,表示任意多列。

     (6).RepeatDirection属性:用与指定RadioButtonList的显示方向。该属性值为Vertical时,列表项以垂直方向排列的形式显示;该属性值为Horzontal时,列表以水平方向排列的形式显示。显示的列数始终由RepeatColumns属性决定。

     (7).RepeatLayout属性:用于设置选项的排列方式。属性值为Table(默认)时,以表结果显示;属性值为Flow时,不以表结构显示。

     (8).SelectedIndex属性:用于获取或设置列表中选定的索引值。

     (9).SelectedItem属性:用于获取列表控件中的选定项。有该属性可获得选定项的Text和Value属性值。

        3.事件

        OnSelectedindexChanged事件。当用户选择了列表中的任意选项时,都将触发OnSelectedindexChanged事件。

« 上一篇下一篇 »