how to bind arraylist with radiobuttonlist in application

We will create an ArrayList of Item objects and bind it to a RadioButtonList control using RadioButtonList control's DataSource property.

In the article - Binding an ArrayList with GridView control in ASP.Net application, we have shown how to create an Item class.

First, we place a RadioButtonList control in an .aspx page and in the Page_Load method, we declare a new ArrayList and add items to it using the Add() method.

Next we set the DataSource property of the RadioButtonList control to ArrayList. Set the DataTextField property of the RadioButtonList control to Code and DataValueField property of the RadioButtonList control to Name. The DataBind() method of the RadioButtonList control binds the data source here arraylist with the RadioButtonList control.

protected void Page_Load(object sender, EventArgs e)
  ArrayList list = new ArrayList();
  list.Add(new Item("I001", "Item1"));
  list.Add(new Item("I002", "Item2"));
  list.Add(new Item("I003", "Item3"));
  list.Add(new Item("I004", "Item4"));

  RadioButtonList1.DataSource = list;
  RadioButtonList1.DataTextField = "Code";
  RadioButtonList1.DataValueField = "Name";