我有两个中继器,它们是nested..Means,有一个中继器,里面还有另一个中继器。
我需要以下格式的数据:
*Transaction Id:1xasd2*
Product1 2 500
*Transaction Id:2asd21*
Product2 1 100
Product3 2 200
那么我如何才能做到这一点呢?
发布于 2011-03-18 14:56:19
我想你是在找:
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
发布于 2017-05-31 15:27:25
可以使用:
var repeater = (Repeater)sender;
var parentItem = (RepeaterItem)repeater.NamingContainer;
<Object> parentDataItem = parentItem.DataItem as <Object>;
(parentDataItem.property)
成功了!
https://stackoverflow.com/questions/5348045
复制相似问题