我有两个嵌套的中继器,我想在repeater1中调用repeater2数据绑定器。 为什么?好吧,我需要重复一些repeater2行。但我尝试这个,repeater2只工作一次,应该工作4次。请帮助!
受保护的Sub Repeater1_ItemDataBound(ByVal sender As Object,ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)处理Repeater1.ItemDataBound
For i = 0 To 4
con.Open()
Dim consulta As String = "SELECT DISTINCT Ordenes.Orden, Ordenes.Id, Ordenes.Codigo, Ordenes.Descripcion, Ordenes.Cantidad, Ordenes.PrecioVenta, " & _
"Ordenes.FechaCreacion, Inventario.CostoUnitario, Inventario.Marca, Inventario.Garantia, Inventario.Modelo, Inventario.Color, Inventario.Serial, " & _
"Inventario.CodigoFabricante, Clientes.Nombres, Clientes.Apellidos, Inv_Imagenes.Enlace FROM Ordenes INNER JOIN Inventario ON Ordenes.Codigo = " & _
"Inventario.Codigo INNER JOIN Clientes ON Ordenes.IdCliente = Clientes.IdCliente INNER JOIN Inv_Imagenes ON Ordenes.Codigo = Inv_Imagenes.Item WHERE " & _
"(Ordenes.id = @idt) AND (Inv_Imagenes.Tipo = 'img') AND (Inv_Imagenes.Orden = 1)"
cmd = New SqlCommand(consulta, con)
cmd.Parameters.AddWithValue("@idt", e.Item.DataItem("id").ToString)
dr = cmd.ExecuteReader
Dim Repeater2 As Repeater = e.Item.FindControl("Repeater2")
Repeater2.DataSource = dr
Repeater2.DataBind()
dr.Close()
con.Close()
Next
End Sub
好的例子,有人订购了4部电话,我需要渲染4行,每个人的电话Imei一个接一个地插入其他表格
答案 0 :(得分:0)
您可以使用e.Item.ItemIndex
进行测试If (e.Item.ItemType = ListItemType.Item) Or _
(e.Item.ItemType = ListItemType.AlternatingItem) Then
//Treat with e.Item.ItemIndex
End If