The RadioButtonList control is similar to ChckBoxlist Control there you can select more than one item and here we user can select only one item from the list.
A radioButtonList control is written to the page in the following construction:
Figure Goes here…..
<asp:RadioButtonList ID="rdlNumber" AutoPostBack="true" runat="server"
onselectedindexchanged="rdlNumber_SelectedIndexChanged">
<asp:ListItem Text="One" />
<asp:ListItem Text="Two" />
<asp:ListItem Text="Three" />
<asp:ListItem Text="Four" />
</asp:RadioButtonList>
When we are playing on event handler for RadioButtonList control we need onselectedindexchanged event.
It looks like this
Figure goes here…..
.aspx
<form id="Form1" runat="server">
<div>
<asp:Label ID="lblHeader" ForeColor="Orange" Text="How many Children?" runat="server" />
<asp:RadioButtonList ID="rdlNumber" AutoPostBack="true" runat="server"
onselectedindexchanged="rdlNumber_SelectedIndexChanged">
<asp:ListItem Text="One" />
<asp:ListItem Text="Two" />
<asp:ListItem Text="Three" />
<asp:ListItem Text="Four" />
</asp:RadioButtonList>
<br />
<asp:Label ID="lblMessage" ForeColor="BlueViolet" runat="server" />
</div>
</form>
.cs
protected void rdlNumber_SelectedIndexChanged(object sender, EventArgs e)
{
lblMessage.Text = "You have selected " + rdlNumber.SelectedItem.ToString();
}
Have fun J
ASP Standard Controls
- ASP Label Control
- ASP TextBox Control
- ASP Button Control
- ASP Link Button Control
- ASP ImageButton Control
- ASP HyperLink Control
- ASP DropDownList Control
- ASP ListBox Control
- ASP CheckBox Control
- ASP CheckBoxList Control
- ASP RadioButton Control
- ASP RadioButtonList Control
- ASP Image Control
- ASP ImageMap Control
- ASP Calendar Control
- ASP Table Control
- ASP BulletedList Control
- ASP Hidden Control
- ASP Literal Control
- ASP AdRotator Control
- ASP Panel Control
- ASP PlaceHolder Control
- ASP FileUpload Control
- ASP UserControl
- ASP Custom Control
Random Tips and Tricks
Tuesday, September 28, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment