Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Hierarchical Grid bind from code behind
posted

I can't find a solution to hierarchical grid, could some please post sample code on how I can make it work.

I have 2 bands in the aspx page, with my colums in the first band. I am binding the grid to a datatable, this works I see the data. But I dont see or know how to show the plus or expand column, which when expanded will show or expand an area where I want to display a FormView. 

 Thanks

Parents
  • 8680
    posted

    Here's how I populated a four-level hierarchical grid from four SqlDataReaders:

    In the designer, I defined all my bands and columns, and turned AutoGenerateColumns off.

    In my Page_Load:

    Me.TenantListUltraWebGrid.DataSource = GetIpmRehabTenantDataset(Me.ProjectId, Me.IncludeFormerTenants)
    Me.TenantListUltraWebGrid.DataBind()

    Which uses this function:

    Public Shared Function GetIpmRehabTenantDataset(ByVal ProjectId As Integer, _
       
    ByVal vIncludeFormerTenants As Boolean) As DataSet

        Dim lResult As New DataSet("TenantDataset")

        Dim lUnitTable As New DataTable("Units")
        lResult.Tables.Add(lUnitTable)
        lResult.Tables(
    "Units").Load(GetIpmRehabUnitsByPropertyId(ProjectId))

        Dim lTenantFamilyTable As New DataTable("Families")
        
    lResult.Tables.Add(lTenantFamilyTable)
        lResult.Tables(
    "Families").Load(GetIpmRehabFamiliesByPropertyId(ProjectId, vIncludeFormerTenants))
        lResult.Relations.Add(lResult.Tables(
    "Units").Columns("UNIT_ID"), _
                                        lResult.Tables(
    "Families").Columns("UNIT_ID"))

        Dim lTenantFamilyMemberTable As New DataTable("FamilyMembers")
       
    lResult.Tables.Add(lTenantFamilyMemberTable)
        lResult.Tables(
    "FamilyMembers").Load(GetIpmRehabFamilyMembersByPropertyId(ProjectId, vIncludeFormerTenants))
        lResult.Relations.Add(lResult.Tables(
    "Families").Columns("FAMILY_ID"), _
                                        lResult.Tables(
    "FamilyMembers").Columns("FAMILY_ID"))

        Dim lIncomeSourceTable As New DataTable("IncomeSources")
       
    lResult.Tables.Add(lIncomeSourceTable)
        lResult.Tables(
    "IncomeSources").Load(GetIpmRehabIncomeSourcesByPropertyId(ProjectId, vIncludeFormerTenants))
        lResult.Relations.Add(lResult.Tables(
    "FamilyMembers").Columns("FAMILY_MEMBER_ID"), _
                                        lResult.Tables(
    "IncomeSources").Columns("FAMILY_MEMBER_ID"))

        Return lResult

    End Function

    The four "GetIpmRehab..." functions each return a SqlDataReader containing all the records related to any of the members of the top-level (lUnitTable) table.

Reply Children