0

我有两个嵌套转发器,我想在转发器 1 中调用转发器 2 数据绑定。为什么?好吧,我需要重复几行repeater2。但我试试这个,repeater2 只工作 1 次,应该工作 4 次。请帮忙!

Protected 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 以插入到其他表格中

4

1 回答 1

0

您可以使用 e.Item.ItemIndex 进行测试

If (e.Item.ItemType = ListItemType.Item) Or _
            (e.Item.ItemType = ListItemType.AlternatingItem) Then

            //Treat with e.Item.ItemIndex


 End If
于 2012-08-28T19:40:29.320 回答