CopyPastehas never been so tasty!

RadioButtonList control in 3.5

by anonymous

  • 0
  • 0
  • 0

RadioButtonList control in 3.5

RadioButtonList control:This control enables the user to select only one list item at a time. Therefore, whenever we want to get a single input from user from a list of items, we can use RadioButtonList control. This control displays a list of radio button either horizontally or vertically.Common Properties: 




It is the space between border and the content of the table cell.


It is the space between table cells.


These are number of columns to use when displaying the radio button group.


This specifies whether the radio button group should be repeated horizontally or vertically.


This is the layout of Radio button group.


This property specifies that the control is a server control.


This specifies on which side of radio button text should appear.

 A Simple Implementation:

 Following is the step by step procedure for the Implementation of a RadioButtonList Control.Step1:  Open visual studio and create a website.Step2:  Open design view of .aspx page and drag a RadioButtonList control, a button and a label on that page.Step3:  Now choose and configure data source from where you want RadioButtonList to fetch data. Now your code at .aspx page will be like below.


    <form id="form1" runat="server">


        <asp:RadioButtonList ID="RadioButtonList1" runat="server"

            DataSourceID="SqlDataSource1" DataTextField="CountryName"        DataValueField="CountryID">


        <asp:SqlDataSource ID="SqlDataSource1" runat="server"

           ConnectionString="<%$ ConnectionStrings:MoviesConnectionString%>"

            SelectCommand="SELECT [CountryID], [CountryName] FROM [Country]">



    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"Text="Submit" />


        <asp:Label ID="Label1" runat="server" Text="lblMovie"></asp:Label>




In the above code I have selected data from Country table of movies database.

 Step4: Now in your code-behind section write following code for displaying selected data in a label.     

protected void Button1_Click(object sender, EventArgs e)


        Label1.Text = RadioButtonList1.SelectedItem.Text;


 Step5: Now press F5. You can see the RadioButtonList is displayed on screen.



Add A Comment: