Web Server Controls->ASP.NET RadioButtonList Control
2007-03-27 09:56
471 查看
Definition and Usage
The RadioButtonList control is used to create a group of radio buttons.Each selectable item in a RadioButtonList control is defined by a ListItem element!
Tip: This control supports data binding!
Properties
Property | Description |
---|---|
AutoPostBack | A Boolean value that specifies whether the form should be posted immediately after the index of the selected item has changed or not. Default is false |
CellPadding | The space, in pixels, between the cell walls and the radio button group |
DataSource | The data source to use |
DataTextField | A field in the data source to be displayed in the radio button group |
DataValueField | A field in the data source that specifies the value of each selectable item in the radio button group |
id | A unique id for the control |
OnSelectedIndexChanged | The name of the function to be executed when the index of the selected item has changed |
RepeatColumns | The number of columns to use when displaying the radio button group. Default is "1" |
RepeatDirection | Specifies whether the radio button group should be repeated horizontally or vertically. Legal values are "Horizontal" and "Vertical". Default is Vertical |
RepeatLayout | The layout of the radio button group. Can be "Table" or "Flow". Default is Table |
runat | Specifies that the control is a server control. Must be set to "server" |
TextAlign | On which side of the radio button the text should appear (right or left) |
Examples
RadiobuttonListASPX Source:
<script runat="server"> Sub submit(sender As Object, e As EventArgs) label1.Text="You selected " & radiolist1.SelectedItem.Text End Sub </script> <html> <body> <form runat="server"> <asp:RadioButtonList id="radiolist1" runat="server"> <asp:ListItem selected="true">Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> </asp:RadioButtonList> <br /> <asp:Button text="Submit" OnClick="submit" runat="server"/> <p><asp:Label id="Label1" runat="server"/></p> </form> </body> </html> |
Output Result:
|
If you select the RadioButtonList "Item 3" and then click the button "Submit", it will show:
|
相关文章推荐
- Web Server Controls->ASP.NET RadioButton Control
- Web Server Controls->ASP.NET HyperLink Control
- Web Server Controls->ASP.NET Table Control
- Web server Controls->ASP.NET TextBox Control
- Web Server Controls->ASP.NET Button Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Image Control
- Web Server Controls->ASP.NET PlaceHolder Control
- Web Server Controls->ASP.NET ImageButton Control
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET TableCell Control
- Web Server Controls->ASP.NET XML Control
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET TableRow Control
- Web Server Controls->ASP.NET AdRotator Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- ASP.NET AJAX Roadmap--Server Controls (9): UpdateProgress Control Overview