简体   繁体   English

嵌套数据列表降至GreatGrandChild级别

[英]Nested Datalists down to GreatGrandChild level

I've been "successful" at getting nested datalists to work through four generations (Parent, Child, GrandChild, GreatGrandChild) but only with recordsets less than 50 and almost a minute of churn time. 我一直在“成功”地使嵌套数据列表通过四代(父代,子代,祖代,祖代,大祖代)来工作,但只有不到50个记录集且流失时间将近一分钟。 Now that I've got about 500 records, the request is timing out. 现在我已经有大约500条记录,该请求正在超时。

I've tried several methods I've found online for successfully getting Parent-Child datalists but I couldn't get recursing to work through to GrandChild without an error for using too many Open Connections. 我已经尝试了几种在网上找到的方法,这些方法可以成功获取父子数据列表,但是我无法递归使用GrandChild,而不会因为使用太多打开连接而出错。

Could anyone share a best practice for a speedy, four-generation nested datalist? 谁能分享快速生成四代嵌套数据列表的最佳实践?

Here is the example code behind for databinding the Child and GrandChild datalists: 以下是用于绑定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

I can only imagine that I'm leaking something somewhere or doing too many round-trips. 我只能想象我在某处泄漏某物或进行了太多往返。 I sure would appreciate some direction and help. 我肯定会得到一些指导和帮助。

Thanks, Rob 谢谢,罗伯

I found this explanation to be very helpful to set up databinding for multiple-level nested datalists. 我发现此说明对于为多级嵌套数据列表设置数据绑定非常有帮助。 While the code was initially very intimidating, I learned it and adapted it to my use. 虽然最初的代码非常令人生畏,但我还是学会了并将其改编成适合自己的用法。

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

Now my nested datalists display in a matter of seconds. 现在,我的嵌套数据列表将在几秒钟内显示出来。

My next step is to learn how to edit the GreatGrandChild datalist in place. 我的下一步是学习如何就地编辑GreatGrandChild数据列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM