Question

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. Now that I've got about 500 records, the request is timing out.

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.

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:

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

No correct solution

OTHER TIPS

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

Now my nested datalists display in a matter of seconds.

My next step is to learn how to edit the GreatGrandChild datalist in place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top