Tags Posts tagged with "examples of asp.net radiobuttonlist control"

examples of asp.net radiobuttonlist control

0 490
what is radiobuttonlist control and how to use it in asp.net

What is RadioButtonList Control and how to use it in ASP.NET

RadioButtonList is a standard control like other controls like RadioButton, Button, CheckBox, CheckBoxList, Label, ListBox, DropDownList etc. In this article I will describe that what is RadioButtonList and how to use it in ASP.NET. Like RadioButton control RadioButtonList control is also used to select only single values out of multiple values. User can select only one value from the RadioButtonList control.


How to insert RadioButtonList control in ASP.NET

To insert RadioButtonList control in your web form first click on the toolbox in your Visual Studio (VS) Framework and then either double click on the RadioButtonList control or drag it your web form to insert it. When you will insert it in your web form then the following coding will appear automatically.



In above coding the ID of the control generates automatically with the default name. You may change it as per your need. Now the next question is that how can we insert items in the list. So just consider the following coding and also see the video…



Properties of CheckBoxList Control


  1. RepeatDirection

In above coding when you will run the program then it will be shown in vertical view by default. To view the list in horizontal view you can use RepeatDirection property of this control. This property has 2 values namely horizontal and vertical. When you set the value to horizontal then the list shows in horizontal view.

  1. RepeatColumn

This property is used to show RadioButtonList items in Columns. Suppose you want to show RadioButtonList in 2 or 3 columns as per your need then you may provide RepeatColumn an integer value like 2 or 3.

  1. RepeatLayout

This property has 2 values namely Flow and Table. When Flow layout is used then items of RadioButtonList shown in a flow means there is no alignment among them, while in Table layout the items of RadioButtonList are shown in the table view. Each item is shown in a column and a row with proper alignment. You may change between both layouts and can feel the change. To understand all above 3 properties just consider the following coding and run that.



  1. AutoPostBack

When this property is set to true then on clicking (check or uncheck) the RadioButtonList control, page postback to server. Postback to server means that the request goes to server to reload the page. This property should be set to true when we require performing any task on clicking the checkbox control and for this we can use SelectedIndexChanged Event to handle this task.


  1. SelectedIndexChanged Event


SelectedIndexChanged event is used to handle any task when someone clicks on the RadioButtonList item. To create SelectedIndexChanged event just go to the property of the RadioButtonList and click in the SelectedIndexChanged textbox and press enter. On pressing enter an event with the default name will be generated. If you want to give any name to this event then type the name of the event and then press enter. Just consider the following coding and also watch the video to understand this….




Note: To execute above event AutoPostBack property of the control must be set to true.


These are the basic features of RadioButtonList control. In my next article I will describe the detailed use of this control. That is all for now. Have a happy coding….

Follow us