嵌套的数据列表一直到GreatGrandChild级别



我"成功"地让嵌套数据列表在四代人(Parent、Child、GrandChild、GreatGrandChild)中工作,但只使用了小于50的记录集和几乎一分钟的流失时间。现在我已经有了大约500条记录,请求的时间已经到了。

我已经尝试了几种我在网上找到的方法,以成功地获得亲子数据列表,但我无法在使用过多开放连接的情况下递归到孙子。

有人能分享一个快速、四代嵌套数据列表的最佳实践吗?

以下是用于数据绑定Child和GrandChild数据列表的示例代码:

Sub Item_Bound_Child(sender As Object, e As DataListItemEventArgs)
    If e.Item.ItemType = ListItemType.Item Or _
        e.Item.ItemType = ListItemType.AlternatingItem Then
        ' Retrieve the Label control in the current DataListItem.
        Dim Parent_Name_Label As Label = _
            CType(e.Item.FindControl("lbl_Parent_Name"), Label)
        Dim s As SqlDataSource = DirectCast(e.Item.FindControl("DataSource_Child_Data"), SqlDataSource)
        s.FilterParameters(0).DefaultValue = Parent_Name_Label.Text
        s.DataBind()

    End If
End Sub
Sub Item_Bound_GrandChild(sender As Object, e As DataListItemEventArgs)
    If e.Item.ItemType = ListItemType.Item Or _
        e.Item.ItemType = ListItemType.AlternatingItem Then
        ' Retrieve the Label control in the current DataListItem.
        Dim Parent_Name_Child_Level_Label As Label = _
            CType(e.Item.FindControl("lbl_Parent_Name_Child_Level"), Label)
        Dim Child_Name_Label As Label = _
            CType(e.Item.FindControl("lbl_Child_Name"), Label)
        Dim s As SqlDataSource = DirectCast(e.Item.FindControl("DataSource_GrandChild_Data"), SqlDataSource)
        s.FilterParameters(0).DefaultValue = Parent_Name_Child_Level_Label .Text
        s.FilterParameters(1).DefaultValue = Child_Name_Label .Text
        s.DataBind()
    End If
End Sub

我只能想象我在某个地方泄露了什么,或者做了太多的往返旅行。我当然会感谢一些指导和帮助。

谢谢,Rob

我发现这个解释对于为多层嵌套数据列表设置数据绑定非常有帮助。虽然代码最初非常吓人,但我学会了它,并根据自己的使用进行了调整。

http://msdn.microsoft.com/en-us/library/aa478959.aspx

现在,我的嵌套数据列表将在几秒钟内显示出来。

我的下一步是学习如何编辑GreatGrandChild数据列表。

最新更新