In this article I will explain with an example, how to bind (populate) Repeater control using Array, ArrayList and Generic List in ASP.Net using C# and VB.Net.
This article will illustrate how to bind (populate) Repeater control using string Array, ArrayList and Generic List of string in ASP.Net.
 
 
HTML Markup
The following HTML Markup consists of an ASP.Net Repeater control rendered as HTML Table. Since the Array, ArrayList or Generic List does not have any named DataItem hence instead of Eval or Bind Container.DataItem is used.  
<asp:Repeater ID="Repeater1" runat="server">
    <HeaderTemplate>
        <table cellspacing="0" rules="all" border="1">
            <tr>
                <th>
                    Customer Names
                </th>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <%# Container.DataItem %>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
 
 
Namespaces
You will need to import the following namespace.
C#
using System.Collections;
 
VB.Net
Imports System.Collections
 
 
Bind (Populate) Repeater control using Array in ASP.Net
Inside the Page Load event of the page, an Array is populated with some string values which ultimately is used to populate the Repeater control.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        //Populate Repeater using Array of string.
        string[] arrNames = new string[4];
        arrNames[0] = "John Hammond";
        arrNames[1] = "Mudassar Khan";
        arrNames[2] = "Suzanne Mathews";
        arrNames[3] = "Robert Schidner";
        Repeater1.DataSource = arrNames;
        Repeater1.DataBind();
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        'Populate Repeater using Array of string.
        Dim arrNames As String() = New String(3) {}
        arrNames(0) = "John Hammond"
        arrNames(1) = "Mudassar Khan"
        arrNames(2) = "Suzanne Mathews"
        arrNames(3) = "Robert Schidner"
        Repeater1.DataSource = arrNames
        Repeater1.DataBind()
    End If
End Sub
 
 
Bind (Populate) Repeater control using ArrayList in ASP.Net
Inside the Page Load event of the page, an ArrayList is populated with some string values which ultimately is used to populate the Repeater control.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        //Populate Repeater using ArrayList.
        ArrayList alstNames = new ArrayList();
        alstNames.Add("John Hammond");
        alstNames.Add("Mudassar Khan");
        alstNames.Add("Suzanne Mathews");
        alstNames.Add("Robert Schidner");
        Repeater1.DataSource = alstNames;
        Repeater1.DataBind();
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        'Populate Repeater using ArrayList.
        Dim alstNames As New ArrayList()
        alstNames.Add("John Hammond")
        alstNames.Add("Mudassar Khan")
        alstNames.Add("Suzanne Mathews")
        alstNames.Add("Robert Schidner")
       Repeater1.DataSource = alstNames
        Repeater1.DataBind()
    End If
End Sub
 
 
Bind (Populate) Repeater control using Generic List in ASP.Net
Inside the Page Load event of the page, a Generic List is populated with some string values which ultimately is used to populate the Repeater control.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        //Populate Repeater using List of string.
        List<string> lstNames = new List<string>();
        lstNames.Add("John Hammond");
        lstNames.Add("Mudassar Khan");
        lstNames.Add("Suzanne Mathews");
        lstNames.Add("Robert Schidner");
        Repeater1.DataSource = lstNames;
        Repeater1.DataBind();
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        'Populate Repeater using List of string.
        Dim lstNames As New List(Of String)()
        lstNames.Add("John Hammond")
        lstNames.Add("Mudassar Khan")
        lstNames.Add("Suzanne Mathews")
        lstNames.Add("Robert Schidner")
        Repeater1.DataSource = lstNames
        Repeater1.DataBind()
    End If
End Sub
 
 
Screenshot
Bind (Populate) Repeater control using Array, ArrayList and Generic List in ASP.Net
 
 
Demo
 
 
Downloads