Search | Contact | Link To Us  

      ASP.NET     

ASP.NET
Dev Environment
Web Forms
Web Controls
ADO .NET
Web User Controls
Deployment
XML Web Services
ASP.NET Feedback Form
Resources
Discussions
VB .NET
About



Advertisement


     HomeASP.NETWeb Controls> RadioButtonList 

RadioButtonList  

The RadioButtonList Web server control is used to display a list of radio buttons. This control provides us with a single-selection radio button group that can be dynamically generated via data binding. The Items property of this control allows us to add items to the control. To determine which item is selected, we need to test the SelectedItem property of the list. The class hierarchy of this control is as follows:

 Object
  Control
   WebControl
    ListControl
     RadioButtonList

RadioButtonList event

The default event of the RadioButtonList is the SelectedIndexChanged which looks like this in code:

Private Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
'Implementation Omitted
End Sub

Notable Properties

Notable properties of the RadioButtonList control are as follows:

Items: Gets/Sets the collection of items in the list
RepeatColumns: Gets/Sets the number of displayed columns in the radio button list
RepeatDirection: Gets/Sets the display direction of radio buttons
RepeatLayout: Gets/Sets the radio button layout
TextAlign: Gets/Sets the radio button's text alignment

RadioButtonListSample

Drag a RadioButonList, TextBox and a Buton control on to a form. Add some items to the radio button list with it's item property. The following code will display the item you select in the radio button list in the textbox when you click the button.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Button1.Click
TextBox1.Text = RadioButtonList1.SelectedItem.Text
End Sub

Live Code Demo


RadioButtonList with 12 items and RepeatColumns property value 4

Select one from the list and hit the submit button 


  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2007 Startvbdotnet.com. All rights reserved.