Search code examples
c#asp.netrepeater

how to get parent repeater item from child repeater?


I have two repeater which are nested..Means there is one repeater and inside that i have another repeater.

I want data in following format:

*Transaction Id:1xasd2*
Product1  2  500
*Transaction Id:2asd21*
Product2  1  100
Product3  2  200

So how can i achieve this?


Solution

  • I think yr looking for:

    Protected Sub rptMaster_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMaster.ItemDataBound
        Dim drv As DataRowView = e.Item.DataItem
        Dim rptChild As Repeater = CType(e.Item.FindControl("rptChild"), Repeater)
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                'Get TransactionID here from master repeater
                Dim lblTransactionID  As Label = drv("TransactionID")
                'bind child repeater here
                rptChild.DataSource = GetData()
                rptChild.DataBind()
        End If
    End Sub