Get selected item, value and text from asp:RadioButtonList (VB.net)
<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
lblMessage.Text = "Selected Text: " _
& rbl1.SelectedItem.Text & "<BR>Selected Value: " _
& rbl1.SelectedItem.Value & "<BR>Selected Index: " _
& rbl1.SelectedIndex
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating a Basic RadioButtonList Control</TITLE>
</HEAD>
<form runat="server">
<BR><BR>
<asp:Label
id="lblMessage"
runat="server"
/>
<BR><BR>
<asp:RadioButtonList
id="rbl1"
runat="server"
cellpadding="5"
cellspacing="5"
repeatcolumns="3"
repeatdirection="Vertical"
repeatlayout="Table"
textalign="Right"
>
<asp:ListItem value="12">Blue</asp:ListItem>
<asp:ListItem value="11">Red</asp:ListItem>
<asp:ListItem value="2">Green</asp:ListItem>
<asp:ListItem value="32">Purple</asp:ListItem>
<asp:ListItem value="8">Black</asp:ListItem>
<asp:ListItem value="15" Selected>Gold</asp:ListItem>
</asp:RadioButtonList>
<BR><BR>
<asp:button
id="butOK"
text="OK"
type="Submit"
onclick="SubmitBtn_Click"
runat="server"
/>
</form>
</BODY>
</HTML>
Related examples in the same category