Friday, 25 May 2012

RadioButtonList

RadioButtonList is an ASP.NET control which is used to provide a list of radiobuttons for a input from the user.The user can check only a single option from a multiple options provides by the RadionButtonList.RadionButtonList is similar to RadioButton control but the difference is that you can add individual RadioButton controls to a page and work with them singly.In simple words you group two or many individual buttons  together.On the otherhand RadioButtonList control a single control that treate as a parent control for a collection of radio button list items.RadioButtonlist control derived from a base ListControl Class and therefore it works like a ListBoxx,DropDownList and CheckBoxList controls.


How to Add RadioButton options Manully?
To add an Radio Button options manully follow first Add RadioButtonList control into your page.When you add a control into your page then a small tag will appear with the tag, click on it.


After click following picture will appear then click on Edit Items then a List Collection Editor box will appear.By clicking on Add button you can add a new option by specifying by setting the Text and Value properties.

How to Add Radio Button options Programmatically?
To add a ListItem into RadioButtonList, firstly you add a RadioButtonList control into your page then goto code behind file by pressing F7.At page_Load event write down the following code.


        protected void Page_Load(object sender, EventArgs e)
        {
            RadioButtonList1.Items.Add(new ListItem("C#","C#"));
            RadioButtonList1.Items.Add(new ListItem("VB","VB"));
            RadioButtonList1.Items.Add(new ListItem("J#","J#"));
            RadioButtonList1.Items.Add(new ListItem("C++", "C++"));
        }


How To a Bind RadioButtonList control to Database?
We can bind a RadioButtonList control to a Database by providing sqlDataSource.

No comments:

Post a Comment