top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

how to bind arraylist with radiobuttonlist in asp.net application

0 votes
452 views
how to bind arraylist with radiobuttonlist in asp.net application
posted May 23, 2016 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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";
  RadioButtonList1.DataBind();
}
answer May 23, 2016 by Shivaranjini
...