Hi,
The below code sets the Web hierarchical Data Source with Web Hierarchical Data Grid. The Complete flow is given.
The code is wrieen in VB .NET.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim webgriddataset As New System.Data.DataSet Dim sqlconn As SqlClient.SqlConnection sqlconn = New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("AConnectionString").ToString()) sqlconn.Open() Dim spName = "sp_Name" Dim sqlDA As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(spName, sqlconn) sqlDA.Fill(webgriddataset, "T1")
Dim WebHierarchicalDataSource1 As Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource Dim datarel(5) As Infragistics.Web.UI.DataSourceControls.DataRelation WebHierarchicalDataSource1 = New Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource
datarel(0) = New Infragistics.Web.UI.DataSourceControls.DataRelation datarel(0).ParentDataViewID = "SqlDataSource1_view1" datarel(0).ChildDataViewID = "SqlDataSource2_view1" datarel(0).ParentColumns = datarel(0).ChildColumns
Dim dataview1(5) As Infragistics.Web.UI.DataSourceControls.DataView dataview1(0) = New Infragistics.Web.UI.DataSourceControls.DataView dataview1(1) = New Infragistics.Web.UI.DataSourceControls.DataView dataview1(0).DataMember = "DefaultView" dataview1(1).DataMember = "DefaultView" dataview1(0).ID = "SqlDataSource1_view1" dataview1(1).ID = "SqlDataSource2_view1"
dataview1(0).DataSource = webgriddataset.Tables(0) dataview1(1).DataSource = webgriddataset.Tables(1)
Dim bf(5) As BoundDataField Dim i As Integer For i = 0 To 1 bf(i) = New BoundDataField bf(i).DataFieldName = webgriddataset.Tables(0).Columns(i).Caption bf(i).Key = "Key" & i bf(i).Header.Text = webgriddataset.Tables(0).Columns(i).Caption.ToLower()
WebHierarchicalDataGrid1.Columns.Add(bf(i))
Next Dim band As Band band = New Band band.DataMember = "SqlDataSource2_view1" band.AutoGenerateColumns = False
For i = 0 To 2 bf(i) = New BoundDataField bf(i).DataFieldName = webgriddataset.Tables(1).Columns(i).Caption bf(i).Key = "Key" & (i + 2) bf(i).Header.Text = webgriddataset.Tables(1).Columns(i).Caption.ToLower() bf(i).Width = New WebControls.Unit(200, UnitType.Pixel) band.Columns.Add(bf(i))
Next WebHierarchicalDataGrid1.Bands.Add(band)
WebHierarchicalDataGrid1.Columns(0).Width = 100 WebHierarchicalDataGrid1.Columns(1).Width = 500 WebHierarchicalDataGrid1.Columns(2).Width = 200
WebHierarchicalDataSource1.DataRelations.Add(datarel(0)) WebHierarchicalDataSource1.DataViews.Add(dataview1(0)) WebHierarchicalDataSource1.DataViews.Add(dataview1(1))
WebHierarchicalDataGrid1.DataSource = WebHierarchicalDataSource1 WebHierarchicalDataGrid1.DataBind()
End Sub
End Class
The output is:
Actually that is the discussion. No Question