GianIsTheName
GianIsTheName

Reputation: 187

Setting the datasource of the child band in UltraGrid

I have an UltraGrid in my Windows Form Application and it has to have two bands. I was able to setup the Parent Band with no problem by using the code below:

        Try
            con.Open()
            da = New SqlDataAdapter("SELECT o.OJTID, o.Surname + ', ' + o.FirstName + ' ' + o.MiddleName AS FullName, t.TotalGrade FROM tblOJTs o INNER JOIN tblTGrades t ON o.OJTID = t.OJTID", con)
            da.Fill(ds, "tblOGrades")
            con.Close()
        Catch ex As Exception
            MsgBox("Error connecting to databe.", MsgBoxStyle.Critical)
            MsgBox(ex.ToString)
            con.Close()
            Exit Sub
        End Try

        UltraGrid1.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.MultiBand
        UltraGrid1.DataSource = ds.Tables("tblOGrades")

The thing now is, I dont know how to set the datasource of the Child Band. I dont encounter such problem with UltraWebGrid because of the Hierarchical DataSource feature but I think its not available for WinForms. I know you guys will help thanks in advance :)

Upvotes: 2

Views: 6455

Answers (1)

Steve
Steve

Reputation: 216313

You need to fill another DataTable in your DataSet with the data related to the first table. After that, you should define the relation between the two datables and finally set the DataSource of the UltraWinGrid to the DataSet itself instead of the single DataTable.

For example:

con.Open()
da = New SqlDataAdapter("SELECT o.OJTID, o.Surname ....", con)
da.Fill(ds, "tblOGrades")
da = new SqlDataAdapter("SELECT .related data....", con)
da.Fill(ds, "tblRelated")
ds.Relations.Add("Grades_Relation", _
   ds.Tables("tblOGrades").Columns("OJTID"), _
   ds.Tables("tblRelated").Columns("relatedID"))
con.Close()

....

UltraGrid1.DataSource = ds

Upvotes: 4

Related Questions