Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Repeater.DataMember Property

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 virtual string DataMember { get; set; }
<asp:Repeater DataMember="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="C#" AutoEventWireup="True" %>
<%@ Import Namespace = "System.Data" %> 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Repeater Example</title>
<script language="C#" runat="server">
       void Page_Load(Object Sender, EventArgs e) {

          if (!IsPostBack) {

             DataTable dt1 = new DataTable("Dt1");

             DataRow dr;

             dt1.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
             dt1.Columns.Add(new DataColumn("StringValue", typeof(string)));
             dt1.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));

             DataSet ds= new DataSet("ds1");            


             for (int i = 0; i < 9; i++) {
                dr = dt1.NewRow();

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


             DataTable dt2 = new DataTable("Dt2");

             dt2.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
             dt2.Columns.Add(new DataColumn("StringValue", typeof(string)));
             dt2.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));           


             for (int i = 0; i < 9; i++) {
                dr = dt2.NewRow();

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


             Repeater1.DataSource = ds;
             Repeater1.DataMember = "Dt1";




    <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

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.