how to bind arraylist with radiobuttonlist in asp.net 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.
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"; RadioButtonList1.DataBind(); }
ArrayList Articles
- convert arraylist to string array
- convert string array to arraylist
- convert datatable into an arraylist
- convert dataset to arraylist in asp.net using c#
- how to retrieve arraylist items in reverse order
- difference between arraylist and list collection
- Arrays vs ArrayList
- how to create and add items into the ArrayList in csharp
- how to add items to the arraylist using an add method
- retrieve arraylist items using enumerators
- retrieve arraylist items using for each loop
- retrieve arraylist items using indexers
- insert items to the arraylist using insert and insertrange method
- remove items from arraylist
- find item in arraylist using indexof method
- bind arraylist with gridview control in asp net application
- how to bind arraylist with dropdownlist in asp net application
Most Viewed
Azure Q & A
Azure Platform
Grid-View
GridView CommandField example
Details-View
GridView and DetailsView Master/Detail page using SqlDataSource control
POCO
POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
Entity Framework
Query entity data model using linq to entities
Array List
Difference between arraylist and list collection
Web Services
How to create a Web service using Visual Studio.net
Form-View
FormView DataBound Event
Object Oriented Programming
Calling base class constructor in C#
Linq
Convert a sequence to a generic list using ToList()method
Project Ideas
Project ideas for students
AccountingSoftware
Accounting Software
MVC
Creating an ASP.Net MVC 3 application
.Net
Using assemblies in .net applications
ASP .Net
How to implement form validation using ASP.Net 2.0 Validation Controls