Current filter:
                                You should refresh the page.
                                  • Hello DevTeam,
                                    With following code I want to show a Master-Detail Gridview:
                                    But all I see is a grid with the Master rows.

                                    Dim objConnection As New SqlConnection(My.Settings.myConnection)
                                    Dim objDataAdapterHoofdTaken As SqlDataAdapter
                                    Dim objDataAdapterSubTaken As SqlDataAdapter
                                    Dim objDataSet1 As New DataSet
                                    Dim strSubTaken As String = "Select * FROM GekoppeldeTaken"
                                    Dim strSQL As String = String.Empty
                                    Try
                                       If booShowOldTasksInOverview = True Then
                                          If cmbPeriode.Text = "" Then
                                             cmbPeriode.Text = "2 Weken"
                                          EndIf
                                          Dim intPositie As Integer = InStr(1, cmbPeriode.Text, " ", CompareMethod.Text)
                                          Dim intDays AsInteger = 7 * CInt(cmbPeriode.Text.Substring(0, intPositie))
                                          Dim datToday AsDate = Now.Date()
                                          Dim datStartDate As Date = datToday.AddDays(-intDays)
                                          Dim strEndDate As String = Format(datStartDate, "MM/dd/yyyy")
                                          Dim strSQLOpenEnAfgehandeldeTaken As String = "Select TaakNummer, TaakSoort, Status, Afdeling, Locatie,     Activiteit, Discipline, Circuit, Actie, Uitvoerder, TaakVoor, StartDatum, PlanDatum, TaakKort, AfhandelDatum FROM Taken WHERE TaakSoort <> 'Aktiepunt' AND (Afhandeldatum IS NULL OR AfhandelDatum >= '" & strEndDate & "') ORDER BY PlanDatum ASC"
                                          strSQL = strSQLOpenEnAfgehandeldeTaken
                                        Else
                                          Dim strSQLOpenTaken As String = "Select TaakNummer, TaakSoort, Status, Afdeling, Locatie, Activiteit, Discipline, Circuit, Actie, Uitvoerder, TaakVoor, StartDatum, PlanDatum, TaakKort FROM Taken WHERE AfhandelDatum Is NULL And TaakSoort <> 'Aktiepunt' ORDER BY PlanDatum ASC"
                                          strSQL = strSQLOpenTaken
                                    End If
                                    objDataAdapterHoofdTaken = New SqlDataAdapter(strSQL, objConnection)
                                    objDataAdapterSubTaken = New SqlDataAdapter(strSubTaken, objConnection)
                                    objDataAdapterHoofdTaken.Fill(objDataSet1, "HoofdTaken")
                                    objDataAdapterSubTaken.Fill(objDataSet1, "SubTaken")
                                    Dim HoofdKeyColumn As DataColumn = objDataSet1.Tables("HoofdTaken").Columns("TaakNummer")
                                    Dim SubKeyColumns As DataColumn = objDataSet1.Tables("SubTaken").Columns("HoofdTaak")
                                    objDataSet1.Relations.Add("HoofdEnSub", HoofdKeyColumn, SubKeyColumns)
                                    If objDataSet1.Tables("HoofdTaken").Rows.Count = 0 Then
                                           MessageBox.Show("Er zijn geen openstaande taken gevonden welke voldoen aan de criteria.", "ETMPro - Openstaande taken ophalen.")
                                      Else
                                        With grdTaken
                                         .DataMember = Nothing
                                         .DataSource = Nothing
                                         .DataSource = objDataSet1.Tables("HoofdTaken")
                                         .ForceInitialize()
                                        ' .Update()
                                        End With
                                        ' GridView1.Columns.Clear()
                                        ' GridView1.PopulateColumns()
                                    End If
                                          objDataAdapterHoofdTaken.Dispose()
                                          objDataAdapterSubTaken.Dispose()
                                          objDataSet1.Dispose()
                                     Catch
                                        MessageBox.Show(Err.Description)
                                     Finally
                                        objConnection.Close()
                                    End Try
                                    End Sub

                                Show all comments
                                • Stas (DevExpress Support) 10.07.2019

                                  Hello,
                                  This behavior can take place if GridView.OptionsDetail.EnableMasterViewMode is disabled. Please make sure that this option is enabled.
                                  If this doesn't help, would you please review the attached project and modify it to reproduce this issue? After that, send this project to us for investigation. This will allow us to find a precise solution for you much faster.
                                  I look forward to your response.

                                • Hein Ruijbroek 10.07.2019

                                  Stas,

                                  This option is already enabled.
                                  At the moment i am changing my code to be like your sample code.
                                  I will keep you informed of the results...

                                  Extra question: Must all Master Rows have a Detail Row?

                                  Regards,
                                  hein

                                • Stas (DevExpress Support) 10.07.2019

                                  No, rows without details will display a disabled expand button.

                                • Hein Ruijbroek 10.07.2019

                                  Hello Stas,

                                  I adjusted my code, but it still doesn't give me the results I want .
                                  Probably the problem is caused by my scenario...

                                  I have a SQL Database with several tables. In one of these tables I have
                                  records that can present a Main Task or a Sub Task. I want the Sub Tasks
                                  to be presented as a detail row of its belonging Master row.

                                  So i have two queries which one of them takes all the Master rows and a query
                                  which takes the detail rows.

                                  Please see my (changed) attached code.

                                  Public Sub OpenstaandeTakenOphalen()
                                  Dim objConnection As New SqlConnection(My.Settings.myConnection)
                                  Dim objDataAdapterHoofdTaken As SqlDataAdapter
                                  Dim objDataAdapterSubTaken As SqlDataAdapter
                                  Dim objDataSet As New DataSet
                                  Dim strSubTaken As String = "Select * FROM Taken WHERE HoofdTaakID IS NOT NULL"
                                  Dim strSQL As String = String.Empty
                                  Try
                                  If booShowOldTasksInOverview = True Then
                                    If cmbPeriode.Text = ""Then
                                      cmbPeriode.Text = "2 Weken"
                                    EndIf
                                  Dim intPositie As Integer = InStr(1, cmbPeriode.Text, " ", CompareMethod.Text)
                                  Dim intDays As Integer = 7 * CInt(cmbPeriode.Text.Substring(0, intPositie))
                                  Dim datToday As Date = Now.Date()
                                  Dim datStartDate As Date = datToday.AddDays(-intDays)
                                  Dim strEndDate As String = Format(datStartDate, "MM/dd/yyyy")
                                  Dim strSQLOpenEnAfgehandeldeTaken As String = "Select ID, TaakNummer, TaakSoort, Status, Afdeling, Locatie, Activiteit, Discipline, Circuit, Actie, Uitvoerder, TaakVoor, StartDatum, PlanDatum, TaakKort, AfhandelDatum, HoofdTaakID FROM Taken WHERE TaakSoort <> 'Aktiepunt' AND (Afhandeldatum IS NULL OR AfhandelDatum >= '" & strEndDate & "') AND HoofdTaakID IS NULL ORDER BY PlanDatum ASC"
                                  strSQL = strSQLOpenEnAfgehandeldeTaken
                                  Else
                                  Dim strSQLOpenTaken As String = "Select ID, TaakNummer, TaakSoort, Status, Afdeling, Locatie, Activiteit, Discipline, Circuit, Actie, Uitvoerder, TaakVoor, StartDatum, PlanDatum, TaakKort, HoofdTaakID FROM Taken WHERE AfhandelDatum Is NULL And TaakSoort <> 'Aktiepunt' AND HoofdTaakID IS NULL ORDER BY PlanDatum ASC"
                                  strSQL = strSQLOpenTaken
                                  End If
                                  objDataAdapterHoofdTaken = New SqlDataAdapter(strSQL, objConnection)
                                  objDataAdapterSubTaken = New SqlDataAdapter(strSubTaken, objConnection)
                                  objDataAdapterHoofdTaken.Fill(objDataSet, "HoofdTaken")
                                  objDataAdapterSubTaken.Fill(objDataSet, "SubTaken")
                                  objDataSet.Tables("HoofdTaken").PrimaryKey = New DataColumn() {objDataSet.Tables("HoofdTaken").Columns("ID")}
                                  objDataSet.Tables("SubTaken").PrimaryKey = New DataColumn() {objDataSet.Tables("SubTaken").Columns("HoofdTaakID")}
                                  If objDataSet.Tables("SubTaken").Rows.Count > 0 Then
                                  objDataSet.Relations.Add("HoofdTakenKey", objDataSet.Tables("HoofdTaken").Columns("ID"), objDataSet.Tables("SubTaken").Columns("HoofdTaakID"))
                                  End If
                                  If objDataSet.Tables("HoofdTaken").Rows.Count = 0 Then
                                  MessageBox.Show("Er zijn geen openstaande taken gevonden welke voldoen aan de criteria.", "ETMPro - Openstaande taken ophalen.")
                                  Else
                                  With grdTaken
                                  .DataMember = Nothing
                                  .DataSource = Nothing
                                  .DataSource = objDataSet.Tables("HoofdTaken")
                                  .ForceInitialize()
                                  .Update()
                                  End With
                                  GridView1.Columns.Clear()
                                  GridView1.PopulateColumns()
                                  GridView1.Columns("ID").Visible = False
                                  End If
                                  objDataAdapterHoofdTaken.Dispose()
                                  objDataAdapterSubTaken.Dispose()
                                  objDataSet.Dispose()
                                  Catch
                                  MessageBox.Show(Err.Description)
                                  Finally
                                      objConnection.Close()
                                  End Try
                                  End Sub

                                • Stas (DevExpress Support) 10.08.2019

                                  I see in your code, master-detail relationships are added conditionally and depend on the following condition:

                                  If objDataSet.Tables("SubTaken").Rows.Count > 0 Then
                                  ...

                                  So a possible reason of this behavior can be that the SubTaken table doesn't contain any rows. So, to overcome this issue, I suggest you add the relationships unconditionally and then make sure that the SubTaken table contains rows.

                                • Stas (DevExpress Support) 10.08.2019

                                  Indeed, I made a mistake. I apologise for this. I've updated my last comment.

                                • Hein Ruijbroek 10.08.2019

                                  Hello Stas,

                                  I checked several times my conditional code and it works fine : "If objDataSet.Tables("SubTaken").Rows.Count > 0 Then ".
                                  And both tables (HoofdTaken and SubTaken) have records. ..

                                  But to be sure, I followed your advice and made the relationships unconditionally…. But still no working Master-Detail....

                                  So, what i did was replacing the gridcontrol with a new one, and now it works….
                                  What i am going to do is checking wether a setting in the gridcontrol is bugging me, or a part of my code is bugging me...
                                  I will come back to you as soon as i found the cause..

                                  regards,
                                  Hein

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Stas,

                                After some tests my conclusion is that a setting in the gridview bugged me.
                                When i replaced the gridcontrol all the Handles were removed from the Gridview events
                                After replacing the gridview i added the Handle to the events one by one. After that Master-Detail
                                s still working as expected. So it had to be (?) the gridview .

                                Thanks for the support.

                                Regards,
                                Hein

                                • Stas (DevExpress Support) 10.09.2019

                                  It is good to hear that your project now works as expected. It is still difficult to say what caused this issue without reproducing it on our side. So, if you have time to create a sample project which reproduces this issue, feel free to share it with me so I can research it and give you a precise answer.

                                • Hein Ruijbroek 10.10.2019

                                  Stas,

                                  Reproducing the situation is almost impossible. When i placed the GridControl on my form, I have
                                  dropped the old one. So the only thing i can do is changing all kind of settings of the gridview
                                  until the situation pops up again…….

                                  So if you don't mind …..:-)

                                  Regards,
                                  Hein