Protected Sub WebHierarchicalDataGrid1_RowIslandsPopulating(ByVal sender As Object, ByVal e As ContainerRowCancelEventArgs) Handles WebHierarchicalDataGrid1.RowIslandsPopulating
'Cancel the default automatic load on demand operation
e.Cancel = True
' Get the data key
Dim key As Integer = CInt(e.Row.DataKey(0))
Dim con As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True")
' Use data key to select only the set of records that belongs to the parent row
Dim com As New SqlCommand("SELECT * FROM Products Where CategoryId = @Id", con)
com.Parameters.AddWithValue("@Id", key)
' Set up a data adapter to fill up a dataset with data
Dim da As New SqlDataAdapter(com)
Dim products As New DataSet()
con.Open()
' Retrieve data
da.Fill(products, "ProductRowIsland")
con.Close()
' Create Container Grid
Dim childGrid As New ContainerGrid()
e.Row.RowIslands.Add(childGrid)
' Bind Grid
childGrid.DataSource = products
childGrid.DataBind()
End Sub