Introduction
This article demonstrates a way to bind Repeater control using Array, ArrayList, and Generic List assortment in ASP.NET using C#.
What is Array?
An array is a fixed-size ordered assortment of components with the same name and same datatype.
What is ArrayList?
An ArrayList is a dynamic arrangement where things are added far away from the array. ArrayList belongs to the System.Collections namespace, thus you would like to import the subsequent namespace.
- using System.Collections;
ArrayList doesn't have sort restriction for storing information. You can store something in ArrayList. Additionally, you'll be able to store multiple kinds of objects in the same ArrayList.
Example
- ArrayList arrList = new ArrayList();
- arrList.Add(1); //int value
- arrList.Add("System.Datetime.Now"); //datetime
- arrList.Add("Nikunj Satasiya");// string
ArrayList stores all the information as objects
Example
- int employeeId= Convert.ToInt32(arrList[0]);
- string employeename = arrList[1].ToString();
- DateTime datetime = Convert.ToDateTime(arrList[2]);
Here, arrList[1] and arrList[2] shows the index/position valuable within the list
Generally, arrayList is especially designed for .NET Framework 2.0 because during that period generic list didn't exist
What is GenericsList?
The syntax to make generic list assortment is similar to the declaration of arrays. You declare the List, populate its members, then access the members.
Generic List is accessible to the System.Collections.Generic namespace, so you would like to first import the subsequent namespace in codebehind.
System.Collections.Generic
In Generic List (List "L"), where L means information sort, like string, int, DateTime and etc.
Example
- List<int> GenericsList = new List<int>();
- GenericsList.Add(1);
- GenericsList.Add(2);
- GenericsList.Add(3);
- for (int i = 0; i < GenericsList.Count; i++)
- {
- Console.WriteLine("My List is : {0}", GenericsList[i]);
- }
Generic List stores all the information of the kind it's declared. So, obtaining the information back is trouble free and no kind of conversions are needed.
Generic List should be used rather than ArrayList unless a specific demand comes for more than the .NET 2.0 Framework.
ASPX Code Markup
The ASPX Code Markup consists of an ASP.Net Repeater control rendered as HTML Table.


DeepanPosted Oct 4, 2017, 11:06 AM
Nicely explained and very useful information