我正在尝试嵌套 2 个中继器。第二个转发器是第一个转发器的 itemDataBind 事件上的数据绑定。
<asp:Repeater ID="FolderRepeater" runat="server" OnItemDataBound="CategoryRepeater_ItemDataBound">
<ItemTemplate>
<p><%# Container.DataItem("DocumentName")%></p>
<asp:Repeater ID="someRepeater" runat="server">
<ItemTemplate>
<p>TEST<%# Container.DataItem("NodeAlias")%></p></br>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
第一个转发器绑定在 PageLoad 上,第二个转发器绑定在第一个转发器的项目数据绑定事件上。但是,似乎没有调用我的 ItemDataBound 事件,因为没有显示第二个中继器项目。
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim datasetFolders As New DataSet()
Dim da As SqlDataAdapter = New SqlDataAdapter()
Dim sqlQry As String
Dim conn As New SqlConnection(CMS.DataEngine.SqlHelper.ConnectionString)
sqlQry = "SELECT * FROM dbo.CMS_Document WHERE DocumentNamePath LIKE '/Galerie/%' AND DocumentExtensions IS NULL"
da.SelectCommand = New SqlCommand(sqlQry, conn)
conn.Open()
da.Fill(datasetFolders)
conn.Close()
FolderRepeater.Dispose()
FolderRepeater.DataSource = datasetFolders
FolderRepeater.DataBind()
End Sub
这将是 itemDataBound 事件。response.write("test") 中的文本未显示在我的网页上,所以我怀疑它从未调用过?
Protected Sub CategoryRepeater_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles FolderRepeater.ItemDataBound
Response.Write("test")
Dim item As RepeaterItem
item = e.Item
Dim imageFolder As New DataSet
Dim da As SqlDataAdapter = New SqlDataAdapter()
Dim sqlQry As String
Dim conn As New SqlConnection(CMS.DataEngine.SqlHelper.ConnectionString)
sqlQry = "SELECT * FROM dbo.View_CONTENT_File_Joined WHERE NodeAliasPath LIKE '/Galerie/" & e.Item.DataItem("DocumentName") & "/%'"
da.SelectCommand = New SqlCommand(sqlQry, conn)
conn.Open()
da.Fill(imageFolder)
conn.Close()
Dim someRepeater As Repeater
someRepeater = e.Item.FindControl("someRepeater")
someRepeater.DataSource = imageFolder
someRepeater.DataBind()
End Sub