Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
Repeater, classe
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
Repeater Class

A data-bound list control that allows custom layout by repeating a specified template for each item displayed in the list.

System..::.Object
  System.Web.UI..::.Control
    System.Web.UI.WebControls..::.Repeater
      System.Web.DynamicData..::.FilterRepeater

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic
Public Class Repeater _
    Inherits Control _
    Implements INamingContainer
C#
public class Repeater : Control, INamingContainer
Visual C++
public ref class Repeater : public Control, 
    INamingContainer
F#
type Repeater =  
    class
        inherit Control
        interface INamingContainer
    end
ASP.NET
<asp:Repeater />

The Repeater type exposes the following members.

  NameDescription
Public methodRepeaterInitializes a new instance of the Repeater class.
Top
  NameDescription
Protected propertyAdapterGets the browser-specific adapter for the control. (Inherited from Control.)
Public propertyAlternatingItemTemplateGets or sets the object implementing System.Web.UI..::.ITemplate that defines how alternating items in the control are displayed.
Public propertyAppRelativeTemplateSourceDirectoryGets or sets the application-relative virtual directory of the Page or UserControl object that contains this control. (Inherited from Control.)
Public propertyBindingContainerInfrastructure. Gets the control that contains this control's data binding. (Inherited from Control.)
Protected propertyChildControlsCreatedGets a value that indicates whether the server control's child controls have been created. (Inherited from Control.)
Public propertyClientIDGets the control ID for HTML markup that is generated by ASP.NET. (Inherited from Control.)
Public propertyClientIDModeGets or sets the algorithm that is used to generate the value of the ClientID property. (Inherited from Control.)
Protected propertyClientIDSeparatorGets a character value representing the separator character used in the ClientID property. (Inherited from Control.)
Protected propertyContextGets the HttpContext object associated with the server control for the current Web request. (Inherited from Control.)
Public propertyControlsGets a System.Web.UI..::.ControlCollection that contains the child controls of the Repeater control. (Overrides Control..::.Controls.)
Public propertyDataItemContainerGets a reference to the naming container if the naming container implements IDataItemContainer. (Inherited from Control.)
Public propertyDataKeysContainerGets a reference to the naming container if the naming container implements IDataKeysControl. (Inherited from Control.)
Public propertyDataMemberGets or sets the specific table in the DataSource to bind to the control.
Public propertyDataSourceGets or sets the data source that provides data for populating the list.
Public propertyDataSourceIDGets or sets the ID property of the data source control that the Repeater control should use to retrieve its data source.
Protected propertyDesignModeGets a value indicating whether a control is being used on a design surface. (Inherited from Control.)
Public propertyEnableThemingGets or sets a value indicating whether themes are applied to this control. (Overrides Control..::.EnableTheming.)
Public propertyEnableViewStateGets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client. (Inherited from Control.)
Protected propertyEventsGets a list of event handler delegates for the control. This property is read-only. (Inherited from Control.)
Public propertyFooterTemplateGets or sets the System.Web.UI..::.ITemplate that defines how the footer section of the Repeater control is displayed.
Protected propertyHasChildViewStateGets a value indicating whether the current server control's child controls have any saved view-state settings. (Inherited from Control.)
Public propertyHeaderTemplateGets or sets the System.Web.UI..::.ITemplate that defines how the header section of the Repeater control is displayed.
Public propertyIDGets or sets the programmatic identifier assigned to the server control. (Inherited from Control.)
Protected propertyIdSeparatorInfrastructure. Gets the character used to separate control identifiers. (Inherited from Control.)
Protected propertyInitializedInfrastructure. Returns a value indicating whether the control has been initialized.
Protected propertyIsBoundUsingDataSourceIDInfrastructure. Gets a value indicating whether the DataSourceID property is set.
Protected propertyIsChildControlStateClearedGets a value indicating whether controls contained within this control have control state. (Inherited from Control.)
Protected propertyIsTrackingViewStateGets a value that indicates whether the server control is saving changes to its view state. (Inherited from Control.)
Protected propertyIsViewStateEnabledGets a value indicating whether view state is enabled for this control. (Inherited from Control.)
Public propertyItemsGets a collection of RepeaterItem objects in the Repeater control.
Public propertyItemTemplateGets or sets the System.Web.UI..::.ITemplate that defines how items in the Repeater control are displayed.
Protected propertyLoadViewStateByIDGets a value indicating whether the control participates in loading its view state by ID instead of index. (Inherited from Control.)
Public propertyNamingContainerGets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same Control..::.ID property value. (Inherited from Control.)
Public propertyPageGets a reference to the Page instance that contains the server control. (Inherited from Control.)
Public propertyParentGets a reference to the server control's parent control in the page control hierarchy. (Inherited from Control.)
Public propertyRenderingCompatibilityGets a value that specifies the ASP.NET version that rendered HTML will be compatible with. (Inherited from Control.)
Protected propertyRequiresDataBindingGets or sets a value indicating whether the Repeater control needs to bind to its specified data source.
Protected propertySelectArgumentsInfrastructure. Gets a DataSourceSelectArguments object that the Repeater control uses when retrieving data from a data source control.
Public propertySeparatorTemplateGets or sets the System.Web.UI..::.ITemplate interface that defines how the separator between items is displayed.
Public propertySiteGets information about the container that hosts the current control when rendered on a design surface. (Inherited from Control.)
Public propertySkinIDGets or sets the skin to apply to the control. (Inherited from Control.)
Public propertyTemplateControlGets or sets a reference to the template that contains this control. (Inherited from Control.)
Public propertyTemplateSourceDirectoryGets the virtual directory of the Page or UserControl that contains the current server control. (Inherited from Control.)
Public propertyUniqueIDGets the unique, hierarchically qualified identifier for the server control. (Inherited from Control.)
Protected propertyViewStateGets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page. (Inherited from Control.)
Protected propertyViewStateIgnoresCaseGets a value that indicates whether the StateBag object is case-insensitive. (Inherited from Control.)
Public propertyViewStateModeGets or sets the view-state mode of this control. (Inherited from Control.)
Public propertyVisibleGets or sets a value that indicates whether a server control is rendered as UI on the page. (Inherited from Control.)
Top
  NameDescription
Protected methodAddedControlCalled after a child control is added to the Controls collection of the Control object. (Inherited from Control.)
Protected methodAddParsedSubObjectNotifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object. (Inherited from Control.)
Public methodApplyStyleSheetSkinApplies the style properties defined in the page style sheet to the control. (Inherited from Control.)
Protected methodBuildProfileTreeInfrastructure. Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page. (Inherited from Control.)
Protected methodClearCachedClientIDInfrastructure. Sets the cached ClientID value to nullNothingnullptra null reference (Nothing in Visual Basic). (Inherited from Control.)
Protected methodClearChildControlStateDeletes the control-state information for the server control's child controls. (Inherited from Control.)
Protected methodClearChildStateDeletes the view-state and control-state information for all the server control's child controls. (Inherited from Control.)
Protected methodClearChildViewStateDeletes the view-state information for all the server control's child controls. (Inherited from Control.)
Protected methodClearEffectiveClientIDModeInfrastructure. Sets the ClientIDMode property of the current control instance and of any child controls to Inherit. (Inherited from Control.)
Protected methodCreateChildControlsInfrastructure. Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. (Overrides Control..::.CreateChildControls()()().)
Protected methodCreateControlCollectionCreates a new ControlCollection object to hold the child controls (both literal and server) of the server control. (Inherited from Control.)
Protected methodCreateControlHierarchyInfrastructure. Creates a control hierarchy, with or without the specified data source.
Protected methodCreateDataSourceSelectArgumentsInfrastructure. Returns the Empty value.
Protected methodCreateItemInfrastructure. Creates a RepeaterItem object with the specified item type and location within the Repeater control.
Public methodDataBind()()()Infrastructure. Binds the Repeater control and all its child controls to the specified data source. (Overrides Control..::.DataBind()()().)
Protected methodDataBind(Boolean)Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event. (Inherited from Control.)
Protected methodDataBindChildrenBinds a data source to the server control's child controls. (Inherited from Control.)
Public methodDisposeEnables a server control to perform final clean up before it is released from memory. (Inherited from Control.)
Protected methodEnsureChildControlsDetermines whether the server control contains child controls. If it does not, it creates child controls. (Inherited from Control.)
Protected methodEnsureDataBoundVerifies that the Repeater control requires data binding and that a valid data source control is specified before calling the DataBind method.
Protected methodEnsureIDCreates an identifier for controls that do not have an identifier assigned. (Inherited from Control.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindControl(String)Searches the current naming container for a server control with the specified id parameter. (Inherited from Control.)
Protected methodFindControl(String, Int32)Infrastructure. Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. You should not override this version of the FindControl method. (Inherited from Control.)
Public methodFocusSets input focus to a control. (Inherited from Control.)
Protected methodGetDataInfrastructure. Returns an IEnumerable interface from the data source.
Protected methodGetDesignModeStateInfrastructure. Gets design-time data for a control. (Inherited from Control.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetRouteUrl(Object)Gets the URL that corresponds to a set of route parameters. (Inherited from Control.)
Public methodGetRouteUrl(RouteValueDictionary)Gets the URL that corresponds to a set of route parameters. (Inherited from Control.)
Public methodGetRouteUrl(String, Object)Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.)
Public methodGetRouteUrl(String, RouteValueDictionary)Gets the URL that corresponds to a set of route parameters and a route name. (Inherited from Control.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUniqueIDRelativeToReturns the prefixed portion of the UniqueID property of the specified control. (Inherited from Control.)
Public methodHasControlsDetermines if the server control contains any child controls. (Inherited from Control.)
Protected methodHasEventsReturns a value indicating whether events are registered for the control or any child controls. (Inherited from Control.)
Protected methodInitializeItemInfrastructure. Populates iteratively the specified RepeaterItem with a sub-hierarchy of child controls.
Protected methodIsLiteralContentInfrastructure. Determines if the server control holds only literal content. (Inherited from Control.)
Protected methodLoadControlStateRestores control-state information from a previous page request that was saved by the SaveControlState method. (Inherited from Control.)
Protected methodLoadViewStateRestores view-state information from a previous page request that was saved by the SaveViewState method. (Inherited from Control.)
Protected methodMapPathSecureRetrieves the physical path that a virtual path, either absolute or relative, maps to. (Inherited from Control.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnBubbleEventInfrastructure. Raises the ItemCommand event if the EventArgs parameter is an instance of RepeaterCommandEventArgs. (Overrides Control..::.OnBubbleEvent(Object, EventArgs).)
Protected methodOnDataBindingInfrastructure. Raises the DataBinding event. (Overrides Control..::.OnDataBinding(EventArgs).)
Protected methodOnDataPropertyChangedInfrastructure. Determines whether data binding is required.
Protected methodOnDataSourceViewChangedSets the RequiresDataBinding property to true.
Protected methodOnInitRaises the Init event. (Overrides Control..::.OnInit(EventArgs).)
Protected methodOnItemCommandRaises the ItemCommand event.
Protected methodOnItemCreatedRaises the ItemCreated event.
Protected methodOnItemDataBoundRaises the ItemDataBound event.
Protected methodOnLoadRaises the Load event and performs other initialization. (Overrides Control..::.OnLoad(EventArgs).)
Protected methodOnPreRenderRaises the PreRender event. (Overrides Control..::.OnPreRender(EventArgs).)
Protected methodOnUnloadRaises the Unload event. (Inherited from Control.)
Protected methodOpenFileGets a Stream used to read a file. (Inherited from Control.)
Protected methodRaiseBubbleEventAssigns any sources of the event and its information to the control's parent. (Inherited from Control.)
Protected methodRemovedControlCalled after a child control is removed from the Controls collection of the Control object. (Inherited from Control.)
Protected methodRenderSends server control content to a provided HtmlTextWriter object, which writes the content to be rendered on the client. (Inherited from Control.)
Protected methodRenderChildrenOutputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client. (Inherited from Control.)
Public methodRenderControl(HtmlTextWriter)Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled. (Inherited from Control.)
Protected methodRenderControl(HtmlTextWriter, ControlAdapter)Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object. (Inherited from Control.)
Protected methodResolveAdapterGets the control adapter responsible for rendering the specified control. (Inherited from Control.)
Public methodResolveClientUrlGets a URL that can be used by the browser. (Inherited from Control.)
Public methodResolveUrlConverts a URL into one that is usable on the requesting client. (Inherited from Control.)
Protected methodSaveControlStateSaves any server control state changes that have occurred since the time the page was posted back to the server. (Inherited from Control.)
Protected methodSaveViewStateSaves any server control view-state changes that have occurred since the time the page was posted back to the server. (Inherited from Control.)
Protected methodSetDesignModeStateSets design-time data for a control. (Inherited from Control.)
Public methodSetRenderMethodDelegateInfrastructure. Assigns an event handler delegate to render the server control and its content into its parent control. (Inherited from Control.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodTrackViewStateCauses tracking of view-state changes to the server control so they can be stored in the server control's StateBag object. This object is accessible through the Control..::.ViewState property. (Inherited from Control.)
Top
  NameDescription
Public eventDataBindingOccurs when the server control binds to a data source. (Inherited from Control.)
Public eventDisposedOccurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested. (Inherited from Control.)
Public eventInitOccurs when the server control is initialized, which is the first step in its lifecycle. (Inherited from Control.)
Public eventItemCommandOccurs when a button is clicked in the Repeater control.
Public eventItemCreatedOccurs when an item is created in the Repeater control.
Public eventItemDataBoundOccurs after an item in the Repeater control is data-bound but before it is rendered on the page.
Public eventLoadOccurs when the server control is loaded into the Page object. (Inherited from Control.)
Public eventPreRenderOccurs after the Control object is loaded but prior to rendering. (Inherited from Control.)
Public eventUnloadOccurs when the server control is unloaded from memory. (Inherited from Control.)
Top
  NameDescription
Public Extension MethodEnableDynamicData(Type)Overloaded. Enables Dynamic Data behavior for the specified data control. (Defined by DataControlExtensions.)
Public Extension MethodEnableDynamicData(Type, Object)Overloaded. Enables Dynamic Data behavior for the specified data control. (Defined by DataControlExtensions.)
Public Extension MethodEnableDynamicData(Type, IDictionary<(Of <(String, Object>)>))Overloaded. Enables Dynamic Data behavior for the specified data control. (Defined by DataControlExtensions.)
Public Extension MethodFindDataSourceControlReturns the data source that is associated with the data control for the specified control. (Defined by DynamicDataExtensions.)
Public Extension MethodFindFieldTemplateReturns the field template for the specified column in the specified control's naming container. (Defined by DynamicDataExtensions.)
Public Extension MethodFindMetaTableReturns the metatable object for the containing data control. (Defined by DynamicDataExtensions.)
Public Extension MethodGetDefaultValuesGets the collection of the default values for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodGetMetaTableGets the table metadata for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodSetMetaTable(MetaTable)Overloaded. Sets the table metadata for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodSetMetaTable(MetaTable, IDictionary<(Of <(String, Object>)>))Overloaded. Sets the table metadata and default value mapping for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodSetMetaTable(MetaTable, Object)Overloaded. Sets the table metadata and default value mapping for the specified data control. (Defined by DynamicDataExtensions.)
Public Extension MethodTryGetMetaTableDetermines whether table metadata is available. (Defined by DynamicDataExtensions.)
Top
  NameDescription
Explicit interface implemetationPrivate propertyIControlBuilderAccessor..::.ControlBuilderFor a description of this member, see IControlBuilderAccessor..::.ControlBuilder. (Inherited from Control.)
Explicit interface implemetationPrivate methodIControlDesignerAccessor..::.GetDesignModeStateFor a description of this member, see IControlDesignerAccessor..::.GetDesignModeState. (Inherited from Control.)
Explicit interface implemetationPrivate methodIControlDesignerAccessor..::.SetDesignModeStateFor a description of this member, see IControlDesignerAccessor..::.SetDesignModeState. (Inherited from Control.)
Explicit interface implemetationPrivate methodIControlDesignerAccessor..::.SetOwnerControlInfrastructure. For a description of this member, see IControlDesignerAccessor..::.SetOwnerControl. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIControlDesignerAccessor..::.UserDataFor a description of this member, see IControlDesignerAccessor..::.UserData. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIDataBindingsAccessor..::.DataBindingsFor a description of this member, see IDataBindingsAccessor..::.DataBindings. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIDataBindingsAccessor..::.HasDataBindingsFor a description of this member, see IDataBindingsAccessor..::.HasDataBindings. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIExpressionsAccessor..::.ExpressionsFor a description of this member, see IExpressionsAccessor..::.Expressions. (Inherited from Control.)
Explicit interface implemetationPrivate propertyIExpressionsAccessor..::.HasExpressionsFor a description of this member, see IExpressionsAccessor..::.HasExpressions. (Inherited from Control.)
Explicit interface implemetationPrivate methodIParserAccessor..::.AddParsedSubObjectFor a description of this member, see IParserAccessor..::.AddParsedSubObject. (Inherited from Control.)
Top

In this topic:

Introduction

The Repeater control is a basic templated data-bound list. It has no built-in layout or styles, so you must explicitly declare all layout, formatting, and style tags within the control's templates.

The Repeater control allows you to split markup tags across the templates. To create a table using templates, include the begin table tag (<table>) in the HeaderTemplate, a single table row tag (<tr>) in the ItemTemplate, and the end table tag (</table>) in the FooterTemplate.

The Repeater control has no built-in selection capabilities or editing support. You can use the ItemCommand event to process control events that are raised from the templates to the control.

Caution noteCaution

This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Control Syntax.

Data Binding

The Repeater control provides two properties to support data binding. To bind data to any collection that implements the System.Collections..::.IEnumerable interface (such as a System.Data..::.DataView, a System.Collections..::.ArrayList, or an array), or the IListSource interface, use the DataSource property to specify the data source. When you set the DataSource property, you must manually write the code to perform data binding. To automatically bind the Repeater control to a data source represented by a data source control, set the DataSourceID property to the ID of the data source control to use. When you set the DataSourceID property, the Repeater control automatically binds to the specified data source control on the first request. Therefore, you do not need to explicitly call the DataBind method unless you have changed data-related properties of the Repeater control.

A Repeater control binds its ItemTemplate and AlternatingItemTemplate to either the data model declared and referenced by its DataSource property or the data source control specified by its DataSourceID property. The HeaderTemplate, FooterTemplate, and SeparatorTemplate are not data-bound.

If the Repeater control's data source is set but no data is returned, the control renders the HeaderTemplate and FooterTemplate with no items. If the data source is nullNothingnullptra null reference (Nothing in Visual Basic), the Repeater is not rendered.

Templates

At a minimum, every Repeater control must define an ItemTemplate. However, other optional templates described in the following table can be used to customize the appearance of the list.

Template name

Description

ItemTemplate

Defines the content and layout of items within the list. This template is required.

AlternatingItemTemplate

If defined, determines the content and layout of alternating (zero-based odd-indexed) items. If not defined, ItemTemplate is used.

SeparatorTemplate

If defined, is rendered between items (and alternating items). If not defined, a separator is not rendered.

HeaderTemplate

If defined, determines the content and layout of the list header. If not defined, a header is not rendered.

FooterTemplate

If defined, determines the content and layout of the list footer. If not defined, a footer is not rendered.

Declarative Syntax

<asp:Repeater
    DataMember="string"
    DataSource="string"
    DataSourceID="string"
    EnableTheming="True|False"
    EnableViewState="True|False"
    ID="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnItemCommand="ItemCommand event handler"
    OnItemCreated="ItemCreated event handler"
    OnItemDataBound="ItemDataBound event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    Visible="True|False"
>
        <AlternatingItemTemplate>
            <!-- child controls -->
        </AlternatingItemTemplate>
        <FooterTemplate>
            <!-- child controls -->
        </FooterTemplate>
        <HeaderTemplate>
            <!-- child controls -->
        </HeaderTemplate>
        <ItemTemplate>
            <!-- child controls -->
        </ItemTemplate>
        <SeparatorTemplate>
            <!-- child controls -->
        </SeparatorTemplate>
</asp:Repeater>
TopicLocation
Comment : ajouter des contrôles à une page Web ASP.NET par programmeGénération d'applications Web ASP.NET
Comment : ajouter des contrôles à une page Web ASP.NET par programmeGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter des contrôles serveur Web Repeater à une page Web FormsGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter des contrôles serveur Web Repeater à une page Web Forms (Visual Studio)Génération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter un contrôle Repeater à une page Web FormsGénération d'applications Web ASP.NET
Comment : créer des modèles de contrôle serveur Web ASP.NETGénération d'applications Web ASP.NET
Comment : créer des modèles de contrôle Web ASP.NET de manière déclarativeGénération d'applications Web ASP.NET
Comment : créer des modèles de contrôle Web ASP.NET de manière déclarativeGénération d'applications Web ASP.NET dans Visual Studio
Comment : créer des modèles de contrôles serveur Web à l'aide du concepteurGénération d'applications Web ASP.NET dans Visual Studio
Comment : créer des modèles de contrôles serveur Web à l'aide du concepteurGénération d'applications Web ASP.NET dans Visual Studio
Comment : créer dynamiquement des modèles de contrôles serveur Web ASP.NETGénération d'applications Web ASP.NET
Comment : créer dynamiquement des modèles de contrôles serveur Web ASP.NETGénération d'applications Web ASP.NET dans Visual Studio
Comment : établir une liaison vers les données d'un contrôle basé sur des modèlesGénération d'applications Web ASP.NET
Comment : établir une liaison vers les données d'un contrôle basé sur des modèlesGénération d'applications Web ASP.NET dans Visual Studio
Comment : établir une liaison vers les données d'un contrôle basé sur des modèles dans Visual StudioGénération d'applications Web ASP.NET dans Visual Studio
Comment : établir une liaison vers les données d'un contrôle basé sur des modèles dans Visual StudioGénération d'applications Web ASP.NET dans Visual Studio
Comment : répondre à des événements Button dans des éléments des contrôles DataList, Repeater ou GridViewGénération d'applications Web ASP.NET
Comment : répondre à des événements de bouton dans des éléments DataList ou RepeaterGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : création et utilisation de pages maîtres ASP.NET dans Visual Web DeveloperGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : création et utilisation de pages maîtres ASP.NET dans Visual Web DeveloperGénération d'applications à l'aide de Visual Web Developer
Procédure pas à pas : liaison de données à un objet métier personnaliséGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : liaison de données à un objet métier personnaliséGénération d'applications Web ASP.NET dans Visual Studio

A Visual Studio Web site project with source code is available to accompany this topic: Download.

The following code example demonstrates how to use two simple Repeater controls on a page. The DataSource property is used to specify the data source for the Repeater control. The first Repeater displays its items in a table; the second Repeater displays its items in a comma-separated list.

Visual Basic
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
 <head>
    <title>Repeater Example</title>
<script language="VB" runat="server">

    Sub Page_Load(Sender As Object, e As EventArgs)
        If Not IsPostBack Then
            Dim values As New ArrayList()

            values.Add(New PositionData("Microsoft", "Msft"))
            values.Add(New PositionData("Intel", "Intc"))
            values.Add(New PositionData("Dell", "Dell"))

            Repeater1.DataSource = values
            Repeater1.DataBind()

            Repeater2.DataSource = values
            Repeater2.DataBind()
        End If
    End Sub

    Public Class PositionData

        Private myName As String
        Private myTicker As String        

        Public Sub New(newName As String, newTicker As String)
            Me.myName = newName
            Me.myTicker = newTicker
        End Sub        

        Public ReadOnly Property Name() As String
            Get
                Return myName
            End Get
        End Property        

        Public ReadOnly Property Ticker() As String
            Get
                Return myTicker
            End Get
        End Property
    End Class

    </script>

 </head>
 <body>

    <h3>Repeater Example</h3>

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

       <b>Repeater1:</b>

       <br />

       <asp:Repeater id="Repeater1" runat="server">
          <HeaderTemplate>
             <table border="1">
                <tr>
                   <td><b>Company</b></td>
                   <td><b>Symbol</b></td>
                </tr>
          </HeaderTemplate>

          <ItemTemplate>
             <tr>
                <td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
                <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
             </tr>
          </ItemTemplate>

          <FooterTemplate>
             </table>
          </FooterTemplate>

       </asp:Repeater>
       <br />

       <b>Repeater2:</b>
       <br />
       <asp:Repeater id="Repeater2" runat="server">

          <HeaderTemplate>
             Company data:
          </HeaderTemplate>

          <ItemTemplate>
             <%# DataBinder.Eval(Container.DataItem, "Name") %> (<%# DataBinder.Eval(Container.DataItem, "Ticker") %>)
          </ItemTemplate>

          <SeparatorTemplate>, </SeparatorTemplate>
       </asp:Repeater>
    </form>
 </body>
 </html>
 
C#
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
 <head>
    <title>Repeater Example</title>
<script language="C#" runat="server">
       void Page_Load(Object Sender, EventArgs e) {
          if (!IsPostBack) {
             ArrayList values = new ArrayList();

             values.Add(new PositionData("Microsoft", "Msft"));
             values.Add(new PositionData("Intel", "Intc"));
             values.Add(new PositionData("Dell", "Dell"));

             Repeater1.DataSource = values;
             Repeater1.DataBind();

             Repeater2.DataSource = values;
             Repeater2.DataBind();
          }
       }

       public class PositionData {

          private string name;
          private string ticker;

          public PositionData(string name, string ticker) {
             this.name = name;
             this.ticker = ticker;
          }

          public string Name {
             get {
                return name;
             }
          }

          public string Ticker {
             get {
                return ticker;
             }
          }
       }

    </script>

 </head>
 <body>

    <h3>Repeater Example</h3>

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

       <b>Repeater1:</b>

       <br />

       <asp:Repeater id="Repeater1" runat="server">
          <HeaderTemplate>
             <table border="1">
                <tr>
                   <td><b>Company</b></td>
                   <td><b>Symbol</b></td>
                </tr>
          </HeaderTemplate>

          <ItemTemplate>
             <tr>
                <td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
                <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
             </tr>
          </ItemTemplate>

          <FooterTemplate>
             </table>
          </FooterTemplate>

       </asp:Repeater>
       <br />

       <b>Repeater2:</b>
       <br />
       <asp:Repeater id="Repeater2" runat="server">

          <HeaderTemplate>
             Company data:
          </HeaderTemplate>

          <ItemTemplate>
             <%# DataBinder.Eval(Container.DataItem, "Name") %> (<%# DataBinder.Eval(Container.DataItem, "Ticker") %>)
          </ItemTemplate>

          <SeparatorTemplate>, </SeparatorTemplate>
       </asp:Repeater>
    </form>
 </body>
 </html>
 

The following code example demonstrates how to use the DataSourceID property to specify the data source for a Repeater control. The DataSourceID property is set to the ID property of the SqlDataSource control used to retrieve the data. When the page is loaded, the Repeater control automatically binds to the data source specified by the SqlDataSource control and the data is displayed to the user.

Visual Basic
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
  <head>
    <title>Repeater.DataSourceID Property Example</title>
</head>

  <body>
    <form id="Form1" runat="server">

      <h3>Repeater.DataSourceID Property Example</h3>

      <asp:repeater id="Repeater1"       
        datasourceid="SqlDataSource1"
        runat="server">

        <headertemplate>
          <table border="1">
            <tr>
              <td><b>Product ID</b></td>
              <td><b>Product Name</b></td>
            </tr>
        </headertemplate>

        <itemtemplate>
          <tr>
            <td> <%# Eval("ProductID") %> </td>
            <td> <%# Eval("ProductName") %> </td>
          </tr>
        </itemtemplate>

        <footertemplate>
          </table>
        </footertemplate>
      </asp:repeater>

            <asp:sqldatasource id="SqlDataSource1"          
            connectionstring="<%$ ConnectionStrings:NorthWindConnection%>" 
        selectcommand="SELECT ProductID, ProductName FROM [Products] Where ProductID <= 10"
        runat="server">
      </asp:sqldatasource>

    </form>      
  </body>
</html>
C#
<%@ page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
  <head>
    <title>Repeater.DataSourceID Property Example</title>
</head>

  <body>
    <form id="Form1" runat="server">

      <h3>Repeater.DataSourceID Property Example</h3>

      <asp:repeater id="Repeater1"       
        datasourceid="SqlDataSource1"
        runat="server">

        <headertemplate>
          <table border="1">
            <tr>
              <td><b>Product ID</b></td>
              <td><b>Product Name</b></td>
            </tr>
        </headertemplate>

        <itemtemplate>
          <tr>
            <td> <%# Eval("ProductID") %> </td>
            <td> <%# Eval("ProductName") %> </td>
          </tr>
        </itemtemplate>

        <footertemplate>
          </table>
        </footertemplate>
      </asp:repeater>

            <asp:sqldatasource id="SqlDataSource1"          
            connectionstring="<%$ ConnectionStrings:NorthWindConnection%>" 
        selectcommand="SELECT ProductID, ProductName FROM [Products] Where ProductID <= 10"
        runat="server">
      </asp:sqldatasource>

    </form>      
  </body>
</html>

.NET Framework

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

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Bibliothèque de classes .NET Framework
Repeater, classe

Contrôle de liste lié aux données permettant une présentation personnalisée, grâce à l'application d'un modèle spécifié à chacun des éléments figurant dans la liste.

System..::.Object
  System.Web.UI..::.Control
    System.Web.UI.WebControls..::.Repeater
      System.Web.DynamicData..::.FilterRepeater

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web (dans System.Web.dll)
Visual Basic
Public Class Repeater _
    Inherits Control _
    Implements INamingContainer
C#
public class Repeater : Control, INamingContainer
VisualC++
public ref class Repeater : public Control, 
    INamingContainer
F#
type Repeater =  
    class
        inherit Control
        interface INamingContainer
    end
ASP.NET
<asp:Repeater />

Le type Repeater expose les membres suivants.

  NomDescription
Méthode publiqueRepeaterInitialise une nouvelle instance de la classe Repeater.
Début
  NomDescription
Propriété protégéeAdapterObtient l'adaptateur spécifique au navigateur pour le contrôle. (Hérité de Control.)
Propriété publiqueAlternatingItemTemplateObtient ou définit l'objet implémentant System.Web.UI..::.ITemplate qui définit l'affichage des éléments de remplacement dans le contrôle.
Propriété publiqueAppRelativeTemplateSourceDirectoryObtient ou définit le répertoire virtuel relatif à l'application de l'objet Page ou UserControl qui contient ce contrôle. (Hérité de Control.)
Propriété publiqueBindingContainerInfrastructure. Obtient le contrôle qui contient la liaison de données de ce contrôle. (Hérité de Control.)
Propriété protégéeChildControlsCreatedObtient une valeur qui indique si des contrôles enfants du contrôle serveur ont été créés. (Hérité de Control.)
Propriété publiqueClientIDObtient l'ID de contrôle pour le balisage HTML généré par ASP.NET. (Hérité de Control.)
Propriété publiqueClientIDModeObtient ou définit l'algorithme utilisé pour générer la valeur de la propriété ClientID. (Hérité de Control.)
Propriété protégéeClientIDSeparatorObtient une valeur de caractère représentant le caractère de séparation utilisé dans la propriété ClientID. (Hérité de Control.)
Propriété protégéeContextObtient l'objet HttpContext associé au contrôle serveur pour la demande Web en cours. (Hérité de Control.)
Propriété publiqueControlsObtient un System.Web.UI..::.ControlCollection qui contient les contrôles enfants du contrôle Repeater. (Substitue Control..::.Controls.)
Propriété publiqueDataItemContainerObtient une référence au conteneur d'attribution de noms si celui-ci implémente IDataItemContainer. (Hérité de Control.)
Propriété publiqueDataKeysContainerObtient une référence au conteneur d'attribution de noms si celui-ci implémente IDataKeysControl. (Hérité de Control.)
Propriété publiqueDataMemberObtient ou définit un tableau spécifique dans DataSource à lier au contrôle.
Propriété publiqueDataSourceObtient ou définit la source de données fournissant les données assurant le remplissage de la liste.
Propriété publiqueDataSourceIDObtient ou définit la propriété ID du contrôle de source de données que le contrôle Repeater doit utiliser pour récupérer sa source de données.
Propriété protégéeDesignModeObtient une valeur indiquant si un contrôle est utilisé sur une aire de conception. (Hérité de Control.)
Propriété publiqueEnableThemingObtient ou définit une valeur indiquant si les thèmes sont appliqués à ce contrôle. (Substitue Control..::.EnableTheming.)
Propriété publiqueEnableViewStateObtient ou définit une valeur indiquant si le contrôle serveur rend persistant son état d'affichage, ainsi que celui de tous les contrôles enfants qu'il contient, sur le client à l'origine de la demande. (Hérité de Control.)
Propriété protégéeEventsObtient la liste des délégués de gestionnaires d'événements pour le contrôle. Cette propriété est en lecture seule. (Hérité de Control.)
Propriété publiqueFooterTemplateObtient ou définit l'interface System.Web.UI..::.ITemplate déterminant l'affichage de la section du pied de page du contrôle Repeater.
Propriété protégéeHasChildViewStateObtient une valeur indiquant si les contrôles enfants du contrôle serveur en cours possèdent des paramètres d'état d'affichage enregistrés. (Hérité de Control.)
Propriété publiqueHeaderTemplateObtient ou définit l'interface System.Web.UI..::.ITemplate déterminant l'affichage de la section de l'en-tête du contrôle Repeater.
Propriété publiqueIDObtient ou définit l'ID programmatique assigné au contrôle serveur. (Hérité de Control.)
Propriété protégéeIdSeparatorInfrastructure. Obtient le caractère utilisé pour séparer des identificateurs de contrôle. (Hérité de Control.)
Propriété protégéeInitializedInfrastructure. Retourne une valeur indiquant si le contrôle a été initialisé.
Propriété protégéeIsBoundUsingDataSourceIDInfrastructure. Obtient une valeur indiquant si la propriété DataSourceID est définie.
Propriété protégéeIsChildControlStateClearedObtient une valeur indiquant si les contrôles contenus dans ce contrôle utilisent l'état du contrôle. (Hérité de Control.)
Propriété protégéeIsTrackingViewStateObtient une valeur qui indique si le contrôle serveur enregistre les modifications apportées à son état d'affichage. (Hérité de Control.)
Propriété protégéeIsViewStateEnabledObtient une valeur indiquant si l'état d'affichage est activé pour ce contrôle. (Hérité de Control.)
Propriété publiqueItemsObtient une collection d'objets RepeaterItem dans le contrôle Repeater.
Propriété publiqueItemTemplateObtient ou définit l'interface System.Web.UI..::.ITemplate déterminant l'affichage des éléments dans le contrôle Repeater.
Propriété protégéeLoadViewStateByIDObtient une valeur indiquant si le contrôle participe au chargement de son état d'affichage par ID et non par index. (Hérité de Control.)
Propriété publiqueNamingContainerObtient une référence au conteneur d'attribution de noms du contrôle serveur, qui crée un espace de noms unique pour différencier les contrôles serveur dont la propriété Control..::.ID possède la même valeur. (Hérité de Control.)
Propriété publiquePageObtient une référence à l'instance de Page qui contient le contrôle serveur. (Hérité de Control.)
Propriété publiqueParentObtient une référence au contrôle parent du contrôle serveur dans la hiérarchie des contrôles de la page. (Hérité de Control.)
Propriété publiqueRenderingCompatibilityObtient une valeur qui spécifie la version ASP.NET avec laquelle le HTML restitué sera compatible. (Hérité de Control.)
Propriété protégéeRequiresDataBindingObtient ou définit une valeur qui indique si le contrôle Repeater doit être lié à sa source de données spécifiée.
Propriété protégéeSelectArgumentsInfrastructure. Obtient un objet DataSourceSelectArguments que le contrôle Repeater utilise lors de la récupération de données d'un contrôle de source de données.
Propriété publiqueSeparatorTemplateObtient ou définit l'interface System.Web.UI..::.ITemplate qui définit l'affichage du séparateur entre les éléments.
Propriété publiqueSiteObtient des informations sur le conteneur qui héberge le contrôle en cours lorsqu'il est rendu sur une aire de conception. (Hérité de Control.)
Propriété publiqueSkinIDObtient ou définit l'apparence à appliquer au contrôle. (Hérité de Control.)
Propriété publiqueTemplateControlObtient ou définit une référence au modèle qui contient ce contrôle. (Hérité de Control.)
Propriété publiqueTemplateSourceDirectoryObtient le répertoire virtuel du Page ou du UserControl qui contient le contrôle serveur en cours. (Hérité de Control.)
Propriété publiqueUniqueIDObtient l'identificateur unique qualifié sur le plan hiérarchique du contrôle serveur. (Hérité de Control.)
Propriété protégéeViewStateObtient un dictionnaire d'informations d'état qui vous permet d'enregistrer et de restaurer l'état d'affichage d'un contrôle serveur entre plusieurs demandes de la même page. (Hérité de Control.)
Propriété protégéeViewStateIgnoresCaseObtient une valeur qui indique si l'objet StateBag respecte la casse. (Hérité de Control.)
Propriété publiqueViewStateModeObtient ou définit le mode d'état d'affichage de ce contrôle. (Hérité de Control.)
Propriété publiqueVisibleObtient ou définit une valeur qui indique si un contrôle serveur est rendu sous la forme d'une interface utilisateur sur la page. (Hérité de Control.)
Début
  NomDescription
Méthode protégéeAddedControlAppelée après l'ajout d'un contrôle enfant à la collection Controls de l'objet Control. (Hérité de Control.)
Méthode protégéeAddParsedSubObjectAvertit le contrôle serveur qu'un élément XML ou HTML a été analysé et l'ajoute à l'objet ControlCollection du contrôle serveur. (Hérité de Control.)
Méthode publiqueApplyStyleSheetSkinApplique les propriétés de style définies dans la feuille de style de la page au contrôle. (Hérité de Control.)
Méthode protégéeBuildProfileTreeInfrastructure. Collecte des informations sur le contrôle serveur et les livre à la propriété Trace à afficher lorsque le traçage est activé pour la page. (Hérité de Control.)
Méthode protégéeClearCachedClientIDInfrastructure. Affecte à la valeur ClientID mise en cache la valeur nullNothingnullptrune référence null (Nothing en Visual Basic). (Hérité de Control.)
Méthode protégéeClearChildControlStateSupprime les informations sur l'état du contrôle des contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode protégéeClearChildStateSupprime les informations sur l'état d'affichage et sur l'état du contrôle de tous les contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode protégéeClearChildViewStateSupprime les informations d'état d'affichage de tous les contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode protégéeClearEffectiveClientIDModeInfrastructure. Affecte la valeur Inherit à la propriété ClientIDMode de l'instance de contrôle actuelle et de tous contrôles enfants. (Hérité de Control.)
Méthode protégéeCreateChildControlsInfrastructure. Appelé par l'infrastructure de page ASP.NET pour avertir les contrôles serveur qui utilisent une implémentation basée sur la composition qu'ils doivent créer tous les contrôles enfants qu'ils contiennent en préparation de la publication ou du rendu. (Substitue Control..::.CreateChildControls()()().)
Méthode protégéeCreateControlCollectionCrée un nouvel objet ControlCollection pour contenir les contrôles enfants (littéraux et serveur) du contrôle serveur. (Hérité de Control.)
Méthode protégéeCreateControlHierarchyInfrastructure. Crée une hiérarchie des contrôles, avec ou sans la source de données spécifiée.
Méthode protégéeCreateDataSourceSelectArgumentsInfrastructure. Retourne la valeur Empty.
Méthode protégéeCreateItemInfrastructure. Crée un objet RepeaterItem avec le type d'élément et l'emplacement spécifiés dans le contrôle Repeater.
Méthode publiqueDataBind()()()Infrastructure. Lie le contrôle Repeater et tous ses contrôles enfants à la source de données spécifiée. (Substitue Control..::.DataBind()()().)
Méthode protégéeDataBind(Boolean)Lie une source de données au contrôle serveur appelé et tous ses contrôles enfants avec une option pour déclencher l'événement DataBinding. (Hérité de Control.)
Méthode protégéeDataBindChildrenLie une source de données aux contrôles enfants du contrôle serveur. (Hérité de Control.)
Méthode publiqueDisposePermet à un contrôle serveur d'effectuer le nettoyage final avant qu'il soit libéré de la mémoire. (Hérité de Control.)
Méthode protégéeEnsureChildControlsDétermine si le contrôle serveur contient des contrôles enfants. S'il ne contient pas de contrôles enfants, il en crée. (Hérité de Control.)
Méthode protégéeEnsureDataBoundVérifie que le contrôle Repeater requiert la liaison de données et qu'un contrôle de source de données valide est spécifié avant d'appeler la méthode DataBind.
Méthode protégéeEnsureIDCrée un identificateur pour les contrôles auxquels aucun identificateur n'est assigné. (Hérité de Control.)
Méthode publiqueEquals(Object)Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.)
Méthode protégéeFinalizeAutorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.)
Méthode publiqueFindControl(String)Recherche un contrôle serveur possédant le paramètre id spécifié dans le conteneur d'attribution de noms actuel. (Hérité de Control.)
Méthode protégéeFindControl(String, Int32)Infrastructure. Recherche le conteneur d'attribution de noms actuel d'un contrôle serveur avec l'id spécifié et un entier, spécifié dans le paramètre pathOffset, qui facilite la recherche. Vous ne devez pas substituer cette version de la méthode FindControl. (Hérité de Control.)
Méthode publiqueFocusAffecte le focus d'entrée à un contrôle. (Hérité de Control.)
Méthode protégéeGetDataInfrastructure. Retourne une interface IEnumerable de la source de données.
Méthode protégéeGetDesignModeStateInfrastructure. Obtient les données au moment du design pour un contrôle. (Hérité de Control.)
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode publiqueGetRouteUrl(Object)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire. (Hérité de Control.)
Méthode publiqueGetRouteUrl(RouteValueDictionary)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire. (Hérité de Control.)
Méthode publiqueGetRouteUrl(String, Object)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire et à un nom d'itinéraire. (Hérité de Control.)
Méthode publiqueGetRouteUrl(String, RouteValueDictionary)Obtient l'URL qui correspond à un jeu de paramètres d'itinéraire et à un nom d'itinéraire. (Hérité de Control.)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode publiqueGetUniqueIDRelativeToRetourne la partie préfixée de la propriété UniqueID du contrôle spécifié. (Hérité de Control.)
Méthode publiqueHasControlsDétermine si le contrôle serveur contient des contrôles enfants. (Hérité de Control.)
Méthode protégéeHasEventsRetourne une valeur indiquant si des événements sont inscrits pour le contrôle ou des contrôles enfants. (Hérité de Control.)
Méthode protégéeInitializeItemInfrastructure. Remplit de manière itérative RepeaterItem spécifié avec une sous-hiérarchie de contrôles enfants.
Méthode protégéeIsLiteralContentInfrastructure. Détermine si le contrôle serveur ne détient qu'un contenu littéral. (Hérité de Control.)
Méthode protégéeLoadControlStateRestaure des informations sur l'état du contrôle à partir d'une demande de page antérieure enregistrée par la méthode SaveControlState. (Hérité de Control.)
Méthode protégéeLoadViewStateRestaure les informations d'état d'affichage à partir d'une demande de page antérieure enregistrée par la méthode SaveViewState. (Hérité de Control.)
Méthode protégéeMapPathSecureRécupère le chemin d'accès physique auquel un chemin d'accès virtuel, absolu ou relatif, correspond. (Hérité de Control.)
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode protégéeOnBubbleEventInfrastructure. Déclenche l'événement ItemCommand si le paramètre EventArgs constitue une instance de RepeaterCommandEventArgs. (Substitue Control..::.OnBubbleEvent(Object, EventArgs).)
Méthode protégéeOnDataBindingInfrastructure. Déclenche l'événement DataBinding. (Substitue Control..::.OnDataBinding(EventArgs).)
Méthode protégéeOnDataPropertyChangedInfrastructure. Détermine si la liaison de données est requise.
Méthode protégéeOnDataSourceViewChangedAffecte la valeur true à la propriété RequiresDataBinding.
Méthode protégéeOnInitDéclenche l'événement Init. (Substitue Control..::.OnInit(EventArgs).)
Méthode protégéeOnItemCommandDéclenche l'événement ItemCommand.
Méthode protégéeOnItemCreatedDéclenche l'événement ItemCreated.
Méthode protégéeOnItemDataBoundDéclenche l'événement ItemDataBound.
Méthode protégéeOnLoadDéclenche l'événement Load et exécute une autre initialisation. (Substitue Control..::.OnLoad(EventArgs).)
Méthode protégéeOnPreRenderDéclenche l'événement PreRender. (Substitue Control..::.OnPreRender(EventArgs).)
Méthode protégéeOnUnloadDéclenche l'événement Unload. (Hérité de Control.)
Méthode protégéeOpenFileObtient un Stream utilisé pour lire un fichier. (Hérité de Control.)
Méthode protégéeRaiseBubbleEventAssigne les sources éventuelles de l'événement et ses informations au parent du contrôle. (Hérité de Control.)
Méthode protégéeRemovedControlAppelée après la suppression d'un contrôle enfant dans la collection Controls de l'objet Control. (Hérité de Control.)
Méthode protégéeRenderEnvoie le contenu du contrôle serveur à un objet HtmlTextWriter fourni, qui écrit le contenu à rendre sur le client. (Hérité de Control.)
Méthode protégéeRenderChildrenRenvoie le contenu des enfants d'un contrôle serveur dans un objet HtmlTextWriter fourni, qui écrit le contenu à rendre sur le client. (Hérité de Control.)
Méthode publiqueRenderControl(HtmlTextWriter)Renvoie le contenu du contrôle serveur dans un objet HtmlTextWriter fourni et stocke des informations de traçage au sujet du contrôle si le traçage est activé. (Hérité de Control.)
Méthode protégéeRenderControl(HtmlTextWriter, ControlAdapter)Génère le contenu du contrôle serveur dans un objet HtmlTextWriter à l'aide d'un objet ControlAdapter fourni. (Hérité de Control.)
Méthode protégéeResolveAdapterObtient l'adaptateur de contrôles responsable du rendu du contrôle spécifié. (Hérité de Control.)
Méthode publiqueResolveClientUrlObtient une URL qui peut être utilisée par le navigateur. (Hérité de Control.)
Méthode publiqueResolveUrlConvertit une URL en une URL que le client soit en mesure d'utiliser. (Hérité de Control.)
Méthode protégéeSaveControlStateEnregistre les modifications éventuellement apportées à l'état du contrôle serveur depuis la publication de la page sur le serveur. (Hérité de Control.)
Méthode protégéeSaveViewStateEnregistre les modifications éventuellement apportées à l'état d'affichage du contrôle serveur depuis la publication de la page sur le serveur. (Hérité de Control.)
Méthode protégéeSetDesignModeStateDéfinit les données au moment du design pour un contrôle. (Hérité de Control.)
Méthode publiqueSetRenderMethodDelegateInfrastructure. Assigne un délégué de gestionnaires d'événements pour générer le rendu du contrôle serveur et de son contenu dans son contrôle parent. (Hérité de Control.)
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Méthode protégéeTrackViewStateProvoque le suivi des modifications de l'état d'affichage pour le contrôle serveur afin qu'elles puissent être stockées dans l'objet StateBag du contrôle serveur. Cet objet est accessible via la propriété Control..::.ViewState. (Hérité de Control.)
Début
  NomDescription
Événement publicDataBindingSe produit lorsque le contrôle serveur se lie à une source de données. (Hérité de Control.)
Événement publicDisposedSe produit lorsqu'un contrôle serveur est libéré de la mémoire, ce qui constitue la dernière étape du cycle de vie d'un contrôle serveur en cas de demande d'une page ASP.NET. (Hérité de Control.)
Événement publicInitSe produit lorsque le contrôle serveur est initialisé, ce qui constitue la première étape de son cycle de vie. (Hérité de Control.)
Événement publicItemCommandSe produit lors d'un clic sur le bouton d'un contrôle Repeater.
Événement publicItemCreatedSe produit lors de la création d'un élément dans le contrôle Repeater.
Événement publicItemDataBoundSe produit après qu'un élément présent dans le contrôle Repeater a été lié aux données, mais avant qu'il soit rendu sur la page.
Événement publicLoadSe produit lorsque le contrôle serveur est chargé dans l'objet Page. (Hérité de Control.)
Événement publicPreRenderSe produit après le chargement de l'objet Control mais avant le rendu. (Hérité de Control.)
Événement publicUnloadSe produit lorsque le contrôle serveur est déchargé de la mémoire. (Hérité de Control.)
Début
  NomDescription
Méthode d'extension publiqueEnableDynamicData(Type)Surchargé. Active le comportement Dynamic Data pour le contrôle de données spécifié. (Défini par DataControlExtensions.)
Méthode d'extension publiqueEnableDynamicData(Type, Object)Surchargé. Active le comportement Dynamic Data pour le contrôle de données spécifié. (Défini par DataControlExtensions.)
Méthode d'extension publiqueEnableDynamicData(Type, IDictionary<(Of <(String, Object>)>))Surchargé. Active le comportement Dynamic Data pour le contrôle de données spécifié. (Défini par DataControlExtensions.)
Méthode d'extension publiqueFindDataSourceControlRetourne la source de données associée au contrôle de données pour le contrôle spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueFindFieldTemplateRetourne le modèle de champ pour la colonne spécifiée dans le conteneur d'attribution de noms du contrôle spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueFindMetaTableRetourne l'objet Metatable pour le contrôle de données conteneur. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueGetDefaultValuesObtient la collection des valeurs par défaut pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueGetMetaTableObtient les métadonnées de table pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueSetMetaTable(MetaTable)Surchargé. Définit les métadonnées de table pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueSetMetaTable(MetaTable, IDictionary<(Of <(String, Object>)>))Surchargé. Définit les métadonnées de table et le mappage des valeurs par défaut pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueSetMetaTable(MetaTable, Object)Surchargé. Définit les métadonnées de table et le mappage des valeurs par défaut pour le contrôle de données spécifié. (Défini par DynamicDataExtensions.)
Méthode d'extension publiqueTryGetMetaTableDétermine si des métadonnées de table sont disponibles. (Défini par DynamicDataExtensions.)
Début
  NomDescription
Implémentation d'interface explicitePropriété privéeIControlBuilderAccessor..::.ControlBuilderPour obtenir une description de ce membre, consultez IControlBuilderAccessor..::.ControlBuilder. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIControlDesignerAccessor..::.GetDesignModeStatePour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.GetDesignModeState. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIControlDesignerAccessor..::.SetDesignModeStatePour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.SetDesignModeState. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIControlDesignerAccessor..::.SetOwnerControlInfrastructure. Pour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.SetOwnerControl. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIControlDesignerAccessor..::.UserDataPour obtenir une description de ce membre, consultez IControlDesignerAccessor..::.UserData. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIDataBindingsAccessor..::.DataBindingsPour obtenir une description de ce membre, consultez IDataBindingsAccessor..::.DataBindings. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIDataBindingsAccessor..::.HasDataBindingsPour obtenir une description de ce membre, consultez IDataBindingsAccessor..::.HasDataBindings. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIExpressionsAccessor..::.ExpressionsPour obtenir une description de ce membre, consultez IExpressionsAccessor..::.Expressions. (Hérité de Control.)
Implémentation d'interface explicitePropriété privéeIExpressionsAccessor..::.HasExpressionsPour obtenir une description de ce membre, consultez IExpressionsAccessor..::.HasExpressions. (Hérité de Control.)
Implémentation d'interface expliciteMéthode privéeIParserAccessor..::.AddParsedSubObjectPour obtenir une description de ce membre, consultez IParserAccessor..::.AddParsedSubObject. (Hérité de Control.)
Début

Dans cette rubrique :

Introduction

Le contrôle Repeater correspond à une liste modélisée liée aux données. Comme il n'intègre pas de dispositions ni de styles intégrés, vous devez explicitement déclarer toutes les balises de présentation, de mise en forme et de style au sein des modèles du contrôle.

Le contrôle Repeater vous permet de fractionner des balises d'un modèle à un autre. Pour créer un tableau à l'aide de modèles, insérez une balise de début de tableau <table>) dans la propriété HeaderTemplate, une balise de ligne de tableau simple (<tr>) dans la propriété ItemTemplate et une balise de fin de tableau (</table>) dans la propriété FooterTemplate.

Le contrôle Repeater ne possède pas de fonctionnalité de sélection ni de prise en charge de l'édition. Vous pouvez utiliser l'événement ItemCommand pour traiter les événements de contrôle qui sont déclenchés des modèles au contrôle.

Remarque AttentionAttention

Ce contrôle peut être utilisé pour afficher des entrées d'utilisateur qui peuvent inclure un script client nuisible. Recherchez dans toutes les informations envoyées par un client un script exécutable, des instructions SQL ou d'autre code avant de les afficher dans votre application. ASP.NET fournit une fonctionnalité de validation de demande d'entrée pour bloquer les scripts et le HTML dans les entrées d'utilisateur (user input). Des contrôles serveur de validation sont également fournis pour valider les entrées d'utilisateur (user input). Pour plus d'informations, consultez Syntaxe des contrôles serveur de validation.

Liaison de données

Le contrôle Repeater fournit deux propriétés pour prendre en charge la liaison de données. Pour lier des données à une collection qui implémente l'interface System.Collections..::.IEnumerable (tel que System.Data..::.DataView, System.Collections..::.ArrayList ou un tableau), ou l'interface IListSource, utilisez la propriété DataSource pour spécifier la source de données. Lorsque vous définissez la propriété DataSource, vous devez écrire manuellement le code permettant d'effectuer la liaison de données. Pour lier automatiquement le contrôle Repeater à une source de données représentée par un contrôle de source de données, attribuez à la propriété DataSourceID la valeur ID du contrôle de source de données à utiliser. Lorsque vous définissez la propriété DataSourceID, le contrôle Repeater se lie automatiquement au contrôle de source de données spécifié lors de la première demande. Par conséquent, vous n'avez pas besoin d'appeler explicitement la méthode DataBind, sauf si vous avez modifié les propriétés liées aux données du contrôle Repeater.

Un contrôle Repeater lie son ItemTemplate et son AlternatingItemTemplate soit avec le modèle de données déclaré et référencé par sa propriété DataSource, soit avec le contrôle de source de données spécifié par sa propriété DataSourceID. Les propriétés HeaderTemplate, FooterTemplate et SeparatorTemplate ne sont pas liées aux données.

Si la source de données du contrôle Repeater est définie, mais qu'aucune donnée n'est retournée, le contrôle restitue alors HeaderTemplate et FooterTemplate sans élément. Si la source de données est nullNothingnullptrune référence null (Nothing en Visual Basic), le contrôle Repeater n'est pas restitué.

Modèles

Chaque contrôle Repeater doit définir ItemTemplate au minimum. D'autres modèles optionnels décrits dans le tableau suivant permettent toutefois de personnaliser la présentation de la liste.

Nom du modèle

Description

ItemTemplate

Définit le contenu et la disposition des éléments dans la liste. Ce modèle est obligatoire.

AlternatingItemTemplate

S'il est défini, le contenu et la disposition d'éléments de remplacement (index impair commençant par zéro) sont alors déterminés. S'il n'est pas défini, ItemTemplate est utilisé.

SeparatorTemplate

S'il est défini, la restitution s'effectue alors entre les éléments (et éléments de remplacement). S'il n'est pas défini, aucun séparateur n'est alors restitué.

HeaderTemplate

S'il est défini, le contenu et la disposition de l'en-tête de liste sont alors déterminés. S'il n'est pas défini, aucun en-tête n'est alors restitué.

FooterTemplate

S'il est défini, le contenu et la disposition du pied de page de liste sont alors déterminés. S'il n'est pas défini, aucun pied de page n'est alors restitué.

Syntaxe déclarative

<asp:Repeater
    DataMember="string"
    DataSource="string"
    DataSourceID="string"
    EnableTheming="True|False"
    EnableViewState="True|False"
    ID="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnItemCommand="ItemCommand event handler"
    OnItemCreated="ItemCreated event handler"
    OnItemDataBound="ItemDataBound event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    Visible="True|False"
>
        <AlternatingItemTemplate>
            <!-- child controls -->
        </AlternatingItemTemplate>
        <FooterTemplate>
            <!-- child controls -->
        </FooterTemplate>
        <HeaderTemplate>
            <!-- child controls -->
        </HeaderTemplate>
        <ItemTemplate>
            <!-- child controls -->
        </ItemTemplate>
        <SeparatorTemplate>
            <!-- child controls -->
        </SeparatorTemplate>
</asp:Repeater>
TopicLocation
Comment : ajouter des contrôles à une page Web ASP.NET par programmeGénération d'applications Web ASP.NET
Comment : ajouter des contrôles à une page Web ASP.NET par programmeGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter des contrôles serveur Web Repeater à une page Web FormsGénération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter des contrôles serveur Web Repeater à une page Web Forms (Visual Studio)Génération d'applications Web ASP.NET dans Visual Studio
Comment : ajouter un contrôle Repeater à une page Web FormsGénération d'applications Web ASP.NET
Comment : créer des modèles de contrôle serveur Web ASP.NETGénération d'applications Web ASP.NET
Comment : créer des modèles de contrôle Web ASP.NET de manière déclarativeGénération d'applications Web ASP.NET
Comment : créer des modèles de contrôle Web ASP.NET de manière déclarativeGénération d'applications Web ASP.NET dans Visual Studio
Comment : créer des modèles de contrôles serveur Web à l'aide du concepteurGénération d'applications Web ASP.NET dans Visual Studio
Comment : créer des modèles de contrôles serveur Web à l'aide du concepteurGénération d'applications Web ASP.NET dans Visual Studio
Comment : créer dynamiquement des modèles de contrôles serveur Web ASP.NETGénération d'applications Web ASP.NET
Comment : créer dynamiquement des modèles de contrôles serveur Web ASP.NETGénération d'applications Web ASP.NET dans Visual Studio
Comment : établir une liaison vers les données d'un contrôle basé sur des modèlesGénération d'applications Web ASP.NET
Comment : établir une liaison vers les données d'un contrôle basé sur des modèlesGénération d'applications Web ASP.NET dans Visual Studio
Comment : établir une liaison vers les données d'un contrôle basé sur des modèles dans Visual StudioGénération d'applications Web ASP.NET dans Visual Studio
Comment : établir une liaison vers les données d'un contrôle basé sur des modèles dans Visual StudioGénération d'applications Web ASP.NET dans Visual Studio
Comment : répondre à des événements Button dans des éléments des contrôles DataList, Repeater ou GridViewGénération d'applications Web ASP.NET
Comment : répondre à des événements de bouton dans des éléments DataList ou RepeaterGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : création et utilisation de pages maîtres ASP.NET dans Visual Web DeveloperGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : création et utilisation de pages maîtres ASP.NET dans Visual Web DeveloperGénération d'applications à l'aide de Visual Web Developer
Procédure pas à pas : liaison de données à un objet métier personnaliséGénération d'applications Web ASP.NET dans Visual Studio
Procédure pas à pas : liaison de données à un objet métier personnaliséGénération d'applications Web ASP.NET dans Visual Studio

Un projet de site Web Visual Studio contenant du code source est disponible pour accompagner cette rubrique : Download.

L'exemple de code suivant illustre comment utiliser deux contrôles Repeater simples sur une page. La propriété DataSource est utilisée pour spécifier la source de données pour le contrôle Repeater. Le premier contrôle Repeater affiche ses éléments dans un tableau, tandis que le deuxième contrôle Repeater affiche ses éléments dans une liste avec la virgule comme séparateur.

Visual Basic
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
 <head>
    <title>Repeater Example</title>
<script language="VB" runat="server">

    Sub Page_Load(Sender As Object, e As EventArgs)
        If Not IsPostBack Then
            Dim values As New ArrayList()

            values.Add(New PositionData("Microsoft", "Msft"))
            values.Add(New PositionData("Intel", "Intc"))
            values.Add(New PositionData("Dell", "Dell"))

            Repeater1.DataSource = values
            Repeater1.DataBind()

            Repeater2.DataSource = values
            Repeater2.DataBind()
        End If
    End Sub

    Public Class PositionData

        Private myName As String
        Private myTicker As String        

        Public Sub New(newName As String, newTicker As String)
            Me.myName = newName
            Me.myTicker = newTicker
        End Sub        

        Public ReadOnly Property Name() As String
            Get
                Return myName
            End Get
        End Property        

        Public ReadOnly Property Ticker() As String
            Get
                Return myTicker
            End Get
        End Property
    End Class

    </script>

 </head>
 <body>

    <h3>Repeater Example</h3>

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

       <b>Repeater1:</b>

       <br />

       <asp:Repeater id="Repeater1" runat="server">
          <HeaderTemplate>
             <table border="1">
                <tr>
                   <td><b>Company</b></td>
                   <td><b>Symbol</b></td>
                </tr>
          </HeaderTemplate>

          <ItemTemplate>
             <tr>
                <td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
                <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
             </tr>
          </ItemTemplate>

          <FooterTemplate>
             </table>
          </FooterTemplate>

       </asp:Repeater>
       <br />

       <b>Repeater2:</b>
       <br />
       <asp:Repeater id="Repeater2" runat="server">

          <HeaderTemplate>
             Company data:
          </HeaderTemplate>

          <ItemTemplate>
             <%# DataBinder.Eval(Container.DataItem, "Name") %> (<%# DataBinder.Eval(Container.DataItem, "Ticker") %>)
          </ItemTemplate>

          <SeparatorTemplate>, </SeparatorTemplate>
       </asp:Repeater>
    </form>
 </body>
 </html>
 
C#
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
 <head>
    <title>Repeater Example</title>
<script language="C#" runat="server">
       void Page_Load(Object Sender, EventArgs e) {
          if (!IsPostBack) {
             ArrayList values = new ArrayList();

             values.Add(new PositionData("Microsoft", "Msft"));
             values.Add(new PositionData("Intel", "Intc"));
             values.Add(new PositionData("Dell", "Dell"));

             Repeater1.DataSource = values;
             Repeater1.DataBind();

             Repeater2.DataSource = values;
             Repeater2.DataBind();
          }
       }

       public class PositionData {

          private string name;
          private string ticker;

          public PositionData(string name, string ticker) {
             this.name = name;
             this.ticker = ticker;
          }

          public string Name {
             get {
                return name;
             }
          }

          public string Ticker {
             get {
                return ticker;
             }
          }
       }

    </script>

 </head>
 <body>

    <h3>Repeater Example</h3>

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

       <b>Repeater1:</b>

       <br />

       <asp:Repeater id="Repeater1" runat="server">
          <HeaderTemplate>
             <table border="1">
                <tr>
                   <td><b>Company</b></td>
                   <td><b>Symbol</b></td>
                </tr>
          </HeaderTemplate>

          <ItemTemplate>
             <tr>
                <td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
                <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
             </tr>
          </ItemTemplate>

          <FooterTemplate>
             </table>
          </FooterTemplate>

       </asp:Repeater>
       <br />

       <b>Repeater2:</b>
       <br />
       <asp:Repeater id="Repeater2" runat="server">

          <HeaderTemplate>
             Company data:
          </HeaderTemplate>

          <ItemTemplate>
             <%# DataBinder.Eval(Container.DataItem, "Name") %> (<%# DataBinder.Eval(Container.DataItem, "Ticker") %>)
          </ItemTemplate>

          <SeparatorTemplate>, </SeparatorTemplate>
       </asp:Repeater>
    </form>
 </body>
 </html>
 

L'exemple de code suivant montre comment utiliser la propriété DataSourceID pour spécifier la source de données d'un contrôle Repeater. La propriété DataSourceID a la valeur de la propriété ID du contrôle SqlDataSource utilisé pour récupérer les données. Lorsque la page est chargée, le contrôle Repeater est automatiquement lié à la source de données spécifiée par le contrôle SqlDataSource et les données sont affichées à l'utilisateur.

Visual Basic
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
  <head>
    <title>Repeater.DataSourceID Property Example</title>
</head>

  <body>
    <form id="Form1" runat="server">

      <h3>Repeater.DataSourceID Property Example</h3>

      <asp:repeater id="Repeater1"       
        datasourceid="SqlDataSource1"
        runat="server">

        <headertemplate>
          <table border="1">
            <tr>
              <td><b>Product ID</b></td>
              <td><b>Product Name</b></td>
            </tr>
        </headertemplate>

        <itemtemplate>
          <tr>
            <td> <%# Eval("ProductID") %> </td>
            <td> <%# Eval("ProductName") %> </td>
          </tr>
        </itemtemplate>

        <footertemplate>
          </table>
        </footertemplate>
      </asp:repeater>

            <asp:sqldatasource id="SqlDataSource1"          
            connectionstring="<%$ ConnectionStrings:NorthWindConnection%>" 
        selectcommand="SELECT ProductID, ProductName FROM [Products] Where ProductID <= 10"
        runat="server">
      </asp:sqldatasource>

    </form>      
  </body>
</html>
C#
<%@ page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
  <head>
    <title>Repeater.DataSourceID Property Example</title>
</head>

  <body>
    <form id="Form1" runat="server">

      <h3>Repeater.DataSourceID Property Example</h3>

      <asp:repeater id="Repeater1"       
        datasourceid="SqlDataSource1"
        runat="server">

        <headertemplate>
          <table border="1">
            <tr>
              <td><b>Product ID</b></td>
              <td><b>Product Name</b></td>
            </tr>
        </headertemplate>

        <itemtemplate>
          <tr>
            <td> <%# Eval("ProductID") %> </td>
            <td> <%# Eval("ProductName") %> </td>
          </tr>
        </itemtemplate>

        <footertemplate>
          </table>
        </footertemplate>
      </asp:repeater>

            <asp:sqldatasource id="SqlDataSource1"          
            connectionstring="<%$ ConnectionStrings:NorthWindConnection%>" 
        selectcommand="SELECT ProductID, ProductName FROM [Products] Where ProductID <= 10"
        runat="server">
      </asp:sqldatasource>

    </form>      
  </body>
</html>

.NET Framework

Pris en charge dans : 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker