2011-03-18 50 views
0

我有兩個嵌套的中繼器。意味着有一箇中繼器和裏面,我有另一箇中繼器。如何從子代中繼器獲取父代轉發器項目?

我要在以下格式的數據:

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

那麼我怎樣才能做到這一點?

+0

當前設計的嵌套式中繼器有什麼問題? – tster 2011-03-18 04:52:36

+0

我想,當我綁定兒童中繼器我想parent.so的交易ID我怎麼能得到它? – 2011-03-18 05:27:10

回答

0

我認爲年尋找:

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 
0

可以使用:

var repeater = (Repeater)sender; 
var parentItem = (RepeaterItem)repeater.NamingContainer; 
<Object> parentDataItem = parentItem.DataItem as <Object>; 
(parentDataItem.property) 

工作!

相關問題