0

我已经“成功”地让嵌套数据列表工作了四代(父母、孩子、孙子、伟大的孙子),但只有少于 50 个的记录集和几乎一分钟的流失时间。现在我有大约 500 条记录,请求正在超时。

我已经尝试了几种我在网上找到的成功获取父子数据列表的方法,但是由于使用太多打开的连接,我无法递归到 GrandChild 工作而不会出错。

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

以下是用于对 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

我只能想象我在某处泄漏了一些东西或者做了太多的往返。我当然会感谢一些指导和帮助。

谢谢,罗伯

4

1 回答 1

0

我发现这个解释对于为多级嵌套数据列表设置数据绑定非常有帮助。虽然代码最初非常令人生畏,但我学会了它并对其进行了调整以适应我的使用。

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

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

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

于 2013-07-17T13:52:13.480 回答