Repeater.DataSource Property

Gets or sets the data source that provides data for populating the list.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

<BindableAttribute(True)> _
Public Overridable Property DataSource As Object
Dim instance As Repeater
Dim value As Object

value = instance.DataSource

instance.DataSource = value
/** @property */
public Object get_DataSource ()

/** @property */
public void set_DataSource (Object value)

public function get DataSource () : Object

public function set DataSource (value : Object)

Property Value

An IEnumerable or IListSource object that contains a collection of values used to supply data to this control. The default value is a null reference (Nothing in Visual Basic).

Exception typeCondition


The DataSource object specified is not a supported source of data for the Repeater control.


The data source cannot be resolved because a value is specified for both the DataSource property and the DataSourceID property.

Use this property to specify the source of data to populate the Repeater control. The DataSource can be any System.Collections.IEnumerable object such as a System.Data.DataView for accessing databases, a System.Collections.ArrayList, a System.Collections.Hashtable, or an array, or an IListSource object. When you set the DataSource property you must manually write the code to bind to the data source.

If the data source specified by the DataSource property contains multiple sources of data, use the DataMember property to specify the specific source to bind to the control. For example, if you have a System.Data.DataSet with multiple tables, you must specify which table to bind to the control. After you have specified the data source, use the DataBind method to bind the data source to the control.

Alternately, you can use the DataSourceID property to automatically bind to a data source represented by a data source control. When you set the DataSourceID property, the Repeater control automatically binds to the specified data source control. You do not need to write code that explicitly calls the DataBind method unless you dynamically change properties of the Repeater control.

If values are specified for both the DataSource property and the DataSourceID property, ASP.NET is not able to resolve the data source and a System.Web.HttpException is thrown.

The following example demonstrates how to specify the DataSource of the Repeater control when the page is loaded.

<%@ Page Language="VB" AutoEventWireup="True" %>
    <script runat="server">

        Sub Page_Load(Sender As Object, e As EventArgs)
            If Not IsPostBack Then
                Dim values As New ArrayList()
                ' Set the DataSource of the Repeater. 
                Repeater1.DataSource = values
            End If
        End Sub
    <h3>Repeater Example</h3>
    <form runat=server>
       <asp:Repeater id=Repeater1 runat="server">
             <table border=1>
                <td> <%# Container.DataItem %> </td>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0