Repeater.DataMember Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the specific table in the DataSource to bind to the control.

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

Public Overridable Property DataMember As String

Property Value

Type: System.String

A string that specifies a table in the DataSource.

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.

The value of this property is stored in view state.

The following example demonstrates how to use the DataMember property to specify a table in the DataSource to bind to the Repeater control.

<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace = "System.Data" %> 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
    <title>Repeater Example</title>
<script language="VB" runat="server">

    Sub Page_Load(Sender As Object, e As EventArgs)

        If Not IsPostBack Then

            Dim dt1 As New DataTable("Dt1")

            Dim dr As DataRow

            dt1.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
            dt1.Columns.Add(New DataColumn("StringValue", GetType(String)))
            dt1.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))

            Dim ds As New DataSet("ds1")


            Dim i As Integer
            For i = 0 To 8
                dr = dt1.NewRow()

                dr(0) = i
                dr(1) = "Item " + i.ToString()
                dr(2) = 1.23 *(i + 1)

            Next i

            Dim dt2 As New DataTable("Dt2")

            dt2.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
            dt2.Columns.Add(New DataColumn("StringValue", GetType(String)))
            dt2.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))


            For i = 0 To 8
                dr = dt2.NewRow()

                dr(0) = i
                dr(1) = "Item " + i.ToString()
                dr(2) = 4.56 *(i + 1)

            Next i

            Repeater1.DataSource = ds
            Repeater1.DataMember = "Dt1"
        End If 
    End Sub



    <h3>Repeater Example</h3>

    <form id="form1" runat="server">

       <br />

       <asp:Repeater id="Repeater1" runat="server">

             <table border="1">

                   <%# DataBinder.Eval(Container.DataItem, "StringValue") %> 
                   <%# DataBinder.Eval(Container.DataItem, "CurrencyValue") %> 




.NET Framework
Available since 1.1
Return to top