asp.net.ph

Repeater.AlternatingItemTemplate Property

System.Web.UI.WebControls Namespace   Repeater Class


Specifies the template to use for alternating items in a Repeater.

Syntax

<asp:repeater ... >

   <alternatingitemtemplate>
      ... template definition here
   </alternatingitemtemplate>

</asp:repeater>

Property Value

An ITemplate interface that defines how the alternating ( zero-based odd-indexed ) items in the Repeater control are rendered.

The property is read/write with no default value.

Remarks

The AlternatingItemTemplate functions in the same way as the ItemTemplate, but rendered for every other row in the Repeater control. You can specify a different appearance for the AlternatingItemTemplate by setting its style properties.

To specify a template for the alternating items in a Repeater, place an <AlternatingItemTemplate> element between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <AlternatingItemTemplate> ... </AlternatingItemTemplate> tags.

Items in the AlternatingItemTemplate are data-bound. To display data in the AlternatingItemTemplate, declare one or more Web server controls and set their data-binding expressions to evaluate to a field in the Repeater control's DataSource.

First Name: <asp:Label runat = "server"
   Text = "<%# Eval ( "FirstName" ) %>" />

For more information, see DataBinding Expression Syntax.

Example

The following example illustrates using the AlternatingItemTemplate to display the odd-indexed items of a Repeater in a different background color.

<itemtemplate>
   <tr>
      <td><%# Eval ( "title" ) %></td>
      <td align = "right"><%# Eval ( 
         "price", "{0:c}" ) %></td></tr>
</itemtemplate>

<alternatingitemtemplate>
   <tr style = "background-color:#eed">
      <td><%# Eval ( "title" ) %></td>
      <td align = "right"><%# Eval ( 
         "price", "{0:c}" ) %></td></tr>
</alternatingitemtemplate>

 Show me 

See Also

Repeater Members   ItemTemplate   HeaderTemplate   FooterTemplate   SeparatorTemplate Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph