1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Protected Sub UltraWebGrid1_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles UltraWebGrid1.InitializeDataSource
'Creating the DataTable Object
Dim dt As New DataTable("Parent")
'Creating the DataTable Columns
dt.Columns.Add("Designation", GetType(String))
dt.Columns.Add("Name", GetType(String))
'Creating the DataTable Rows
dt.Rows.Add(New Object() {"DSE", "John"})
dt.Rows.Add(New Object() {"SSE", "Mike"})
dt.Rows.Add(New Object() {"ASE", "Eric"})
'Creating the DataTable Object
Dim dt1 As New DataTable("Child")
'Creating the DataTable Columns
dt1.Columns.Add("Designation", GetType(String))
dt1.Columns.Add("Address", GetType(String))
'Creating the DataTable Rows
dt1.Rows.Add(New Object() {"DSE", "XYZ"})
dt1.Rows.Add(New Object() {"SSE", "ABC"})
dt1.Rows.Add(New Object() {"ASE", "QWE"})
dt1.Rows.Add(New Object() {"DSE", "PradeepK"})
dt1.Rows.Add(New Object() {"SSE", "ChandradeepM"})
dt1.Rows.Add(New Object() {"ASE", "SaurabhB"})
'Creating the DataSet Object
Dim ds As New DataSet
'adding the table object to the the DataSet.
ds.Tables.Add(dt)
ds.Tables.Add(dt1)
'Creating Relationship using the DataSet using the first columns of the 'First table parent and child
ds.Relations.Add(ds.Tables("Parent").Columns(0), ds.Tables("Child").Columns(0))
'Creating ViewType to Hierarchical to have Hierarchical relationship
UltraWebGrid1.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Hierarchical
'Assigning the database/Dataset to UltraWebGrid's DataSource
UltraWebGrid1.DataSource = ds
UltraWebGrid1.DataBind()
End Sub |
Partager