0

我正在尝试嵌套 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
4

2 回答 2

0

问题在于:

FolderRepeater.Dispose()

似乎 dispose 禁用了未来的事件?无论如何,现在我评论了它,它的工作原理。

于 2013-08-21T13:47:37.373 回答
0

很高兴您已经在这里发现了问题:

FolderRepeater.Dispose()
FolderRepeater.DataSource = datasetFolders
FolderRepeater.DataBind()

如果这不是打字错误,那么您应该认真阅读该Dispose()功能的正确使用方法。当您搜索网络时,有很多关于此的信息,即:

于 2013-08-21T13:58:40.287 回答