Hi,
I am trying to bind the WebHierarchicalDataGrid in code and have successfully managed to retrieve the initial parent data. When I click on the Expand Row arrow the grid posts back but the row does not expand to show the child data. Can anyone see hwy this might be happening from the code below.
Thanks
Luke
Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim MainDS As New WebHierarchicalDataSource
Dim ProductView As New Infragistics.Web.UI.DataSourceControls.DataView
ProductView.ID =
"ProductDataView"
ProductView.DataSource = sdsShowAllProducts
MainDS.DataViews.Add(ProductView)
Dim DocumentsView As New Infragistics.Web.UI.DataSourceControls.DataView
DocumentsView.ID =
"DocumentDataView"
DocumentsView.DataSource = sdsShowAllDocuments
MainDS.DataViews.Add(DocumentsView)
Dim ProductNoRelation As New Infragistics.Web.UI.DataSourceControls.DataRelation(ProductView.ID, "ProductNo", DocumentsView.ID, "ProductNo")
MainDS.DataRelations.Add(ProductNoRelation)
CAPGrid.DataSource = MainDS
If Not Page.IsPostBack Then
AddParentBand(CAPGrid)
AddChildBand(CAPGrid)
End If
End Sub
Private Sub AddParentBand(ByRef Grid As Infragistics.Web.UI.GridControls.WebHierarchicalDataGrid)
'the grid is the root band
Grid.AutoGenerateBands =
False
Grid.Key =
Grid.DataKeyFields =
"ProductNo"
AddBandColumn(Grid,
"ProductNo", "", True, True)
"Product Name", "", False, True)
Private
Sub AddChildBand(ByRef Grid As Infragistics.Web.UI.GridControls.WebHierarchicalDataGrid)
Dim ChildBand As New Infragistics.Web.UI.GridControls.Band
ChildBand.Key = "DocumentDataView"
ChildBand.DataKeyFields =
Grid.Bands.Add(ChildBand)
"ProductNo", "", True, False)
"Doc1", "", False, False)
Sub AddBandColumn(ByRef Grid As Infragistics.Web.UI.GridControls.WebHierarchicalDataGrid, ByVal DataField As String, ByVal Caption As String, ByVal Hidden As Boolean, ByVal Parent As Boolean)
Dim boundfld1 As New BoundDataField(True)
boundfld1.Key = DataField
boundfld1.DataFieldName = DataField
boundfld1.Hidden = Hidden
boundfld1.Header.Text = Caption
If Parent Then
Grid.Columns.Add(boundfld1)
Else
Grid.Bands(0).Columns.Add(boundfld1)
Here is a very basic website displaying the problem I have using version 10.3 for .Net4.0. I wasn't sure if my previous post was very clear.
This has been resolved. Just needed to add the Primary Keys to the tables in the code behind.