我有两个嵌套的中继器。只有一个中继器,里面有另一个中继器。
我想要以下格式的数据:
*Transaction Id:1xasd2*
Product1 2 500
*Transaction Id:2asd21*
Product2 1 100
Product3 2 200
那我怎么能实现这个目标呢?
答案 0 :(得分: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
答案 1 :(得分:0)
可以使用:
var repeater = (Repeater)sender;
var parentItem = (RepeaterItem)repeater.NamingContainer;
<Object> parentDataItem = parentItem.DataItem as <Object>;
(parentDataItem.property)
工作!