Link to home
Start Free TrialLog in
Avatar of AJ0718
AJ0718

asked on

Repeater ItemDataBound Skipping First Record

My repeater is generally working well but for some reason is skipping the data binding to a control for the first item in the repeater. The code seems pretty straightforward to me but I am obviously missing something. Can one of you experts help?

Protected Sub rptGrants_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)
        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim GrantID As HiddenField = DirectCast(e.Item.FindControl("hfGrantID"), HiddenField)
            Dim iz As ImageZoom = DirectCast(e.Item.FindControl("ImageZoom1"), ImageZoom)
            Dim cm As New SqlCommand("PBR_SelectGrantPhotos", cn)
            cm.CommandType = CommandType.StoredProcedure
            cm.Parameters.Add("@GrantID", SqlDbType.Int).Value = GrantID.Value
            Try
                cn.Open()
                Dim izda As New SqlDataAdapter(cm)
                Dim izds As New DataSet
                izda.Fill(izds)
                iz.DataSource = izds
                iz.DataBind()
            Catch ex As Exception
            Finally
                cn.Close()
            End Try
        End If
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ess Kay
Ess Kay
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AJ0718
AJ0718

ASKER

I can't remember how I solved this but I finally got it working somehow. You get the points for at least acknowledging I had asked a question :-). Sometimes just a little validation is nice. Thanks.