The RadioButtonList control, like the DropDownList control, enables a user to select only one list item at a time. The RadioButttonList control displays a list of radio buttons that can be arranged either horizontally or vertically.
The RadioButtonList control includes three properties that have an effect on its layout:
RepeatColumns The number of columns of radio buttons to display.
RepeatDirection The direction that the radio buttons are repeated. Possible values are Horizontal and Vertical.
RepeatLayout Determines whether the radio buttons are displayed in an HTML table. Possible values are Table and Flow.
By default, the radio buttons rendered by the RadioButtonList control are rendered in an HTML table. If you set the RepeatLayout property to the value Flow, then the radio buttons are not rendered in a table. Even when the RadioButtonList renders its items in Flow layout mode, you can specify multiple columns
Code Example :
< %@ Page Language="VB" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
< runat="server">
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
lblStudent.Text = rblStudent.SelectedItem.Text
End Sub
< /script>
< xmlns="http://www.w3.org/1999/xhtml">
< id="Head1" runat="server">
<>Show RadioButtonList< /title>
< /head>
< body>
< id="form1" runat="server">
< form id="form1" runat="server">
< div>
< asp:RadioButtonList
id="rblStudent"
DataSourceID="srcStudent"
DataTextField="name"
DataValueField="id"
RepeatColumns="3"
Runat="server" />
< id="btnSubmit" text="Submit" runat="server" onclick="btnSubmit_Click">
< id="lblStudent" runat="server">
< id="srcStudent" selectcommand="SELECT id, name FROM student" connectionstring="">"
Runat="server" />
< /div>
< /form>
< /body>
< /html>
No comments:
Post a Comment