0

在 VB.NET 中工作,在中继器中。如果数据项的字段设置为 true,我只想显示部分转发器。

我正在努力写一行来实现这一点,但我正在尝试这样做:

<% If '<%# Container.DataItem.IsLive%>' Then %>
   <asp:PlaceHolder ...
<% End If%>

任何帮助表示赞赏

4

2 回答 2

1
<asp:PlaceHolder runat="server" Visible='Eval("IsLive")'>
...
</asp:PlaceHolder>
于 2012-06-08T09:55:38.493 回答
1

您可以在 repeater1_ItemDataBound 事件中做到这一点:

Private Sub repeater1_ItemDataBound(Sender As [Object], e As RepeaterItemEventArgs)
       ' This event is raised for the header, the footer, separators, and items.
       ' Execute the following logic for Items and Alternating Items.
       If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
              Dim PlaceHolder1 As PlaceHolder = DirectCast(e.Item.FindControl("PlaceHolder1"), PlaceHolder)
        If (e.Item.DataItem).IsLive Then
          PlaceHolder1.Visible = False
        End If
       End If
End Sub
于 2012-06-08T09:58:57.937 回答