• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

Finding a repeater item by index?

I have the following repeater:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="Repeater_ItemDataBound" >
      <ul id="navbar">
          <asp:ImageButton ID="imgButton" ImageUrl='<%# Bind("Image") %>' runat="server" PostBackUrl='<%# Bind("Path") %>'
            AlternateText='<%# Bind("AltText") %>' CssClass='<%# Bind("Clicked") %>' /></span>

In the Repeater_ItemDataBound is it possible to get a previously bound item by index?

For example say that I was binding the 5th item in the repeater, is it possible to get access to the first item so that I can change the imagebuttons style sheet?

1 Solution
Kamal KhaleefaInformation Security SpecialistCommented:
you can assign a style sheet by the following

  e.Row.Attributes("onMouseOver") = "this.className='RSHover'"
            If e.Row.RowIndex Mod 2 = 0 Then
                e.Row.Attributes("onMouseOut") = "this.className='GridRowStyle'"
                e.Row.Attributes("onMouseOut") = "this.className='GridAlternatingRowStyle'"
            End If


Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now