我已经“成功”地让嵌套数据列表工作了四代(父母、孩子、孙子、伟大的孙子),但只有少于 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
我只能想象我在某处泄漏了一些东西或者做了太多的往返。我当然会感谢一些指导和帮助。
谢谢,罗伯