Add ListItem to RadioButtonList : Radio Button List « Asp Control « ASP.Net






Add ListItem to RadioButtonList


<script language="C#" runat="server">
protected void Page_Load(object o, EventArgs e) {
    if(!IsPostBack) {
        ListItem item;
        item = new ListItem("A", "1");
        languageRadioButtonList.Items.Add(item);
        item = new ListItem("B", "2");
        languageRadioButtonList.Items.Add(item);
        item = new ListItem("C", "3");
        languageRadioButtonList.Items.Add(item);
    }
}

protected void DropDownListSelectionChanged(object o, EventArgs e) {
    favoriteLanguage.Text = languageRadioButtonList.SelectedItem.Value;
}
</script>
<form runat="server">
<asp:RadioButtonList 
    id="languageRadioButtonList"
    runat="server" 
    OnSelectedIndexChanged="DropDownListSelectionChanged" >
</asp:RadioButtonList><br/>
Favorite Language: <b><asp:label runat="server" id="favoriteLanguage" style="color:blue" /></b><br />
<asp:button runat="server" Text="Submit"/>
</form>

 








Related examples in the same category

1.Get selected item, value and text from asp:RadioButtonList (VB.net)
2.On radiobutton list changed (VB.net)
3.Setting and Retrieving the Selected Item in a RadioButton Control Group (VB.net)
4.Set asp:RadioButtonList Repeat Layout (VB.net)
5.Select case for asp:radiobuttonlist (VB.net)
6.Get selected item value from asp:radiobuttonlist (VB.net)
7.Get selected radio button from radio button list (C#)
8.select case statement for asp:radiobuttonlist (C#)
9.Get selected value from asp:radiobuttonlist (C#)
10.RadioButtonList Control