We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

deleting child rows in a hierarchical

Hi I have a old and very important problem in a VB.NET app. I use a GridDataBoundGrid as a hierarchical with 2 tables. Everything works fine instead of child row delete. I can reproduce it in the little project attached... This project was created by you for someone in the forum.... UpdateableExpandGrid_VB_3994.zip So, in this project, you cant add a new child to a row, after deleting all their child... The little cross in the left disappears... How to solve that problem? Just for info, I use Syncfusion 2051. Thanks a lot! bye Syl

2 Replies

AD Administrator Syncfusion Team May 13, 2004 06:47 AM UTC

In the sample I added a InsertChildAtCurrentRow button using the code in the handler below. It seems to work. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cc As GridCurrentCell = Me.gridDataBoundGrid1.CurrentCell Dim rs As GridBoundRecordState = Me.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(cc.RowIndex) ''add a new record to the child level Dim o As Object = rs.ListManager.Current Dim drv As DataRowView = CType(o, DataRowView) Dim dr As DataRow = drv.Row If rs.LevelIndex < 2 Then Dim dt As DataTable = Me.dSet.Tables(rs.LevelIndex + 1) ''get the table Dim newRow As DataRow = dt.NewRow() Dim values As Object() = Nothing Select Case rs.LevelIndex Case 0 Me.numberOfChildren += 1 ''pkValue = this.numberOfChildren; values = New Object() {Me.numberOfChildren, String.Format("ChildName{0}", Me.numberOfChildren), dr(0)} Case 1 Me.numberOfGrandChildren += 1 ''pkValue = this.numberOfGrandChildren; values = New Object() {Me.numberOfGrandChildren, String.Format("GrandChildName{0}", numberOfGrandChildren), dr(0), dt.Columns("FavSport").DefaultValue} Case Else Throw New IndexOutOfRangeException("Improper index") End Select newRow.ItemArray = values dt.Rows.Add(newRow) Dim parentLevel As Integer = rs.LevelIndex - 1 If rs.LevelIndex = 0 Then Me.gridDataBoundGrid1.Model.BeginUpdate() Dim dt1 As DataTable = Me.gridDataBoundGrid1.DataSource Me.gridDataBoundGrid1.DataSource = Nothing Me.gridDataBoundGrid1.DataSource = dt1 Me.gridDataBoundGrid1.EndUpdate() Else Dim row As Integer = cc.RowIndex - 1 If row > Me.gridDataBoundGrid1.Model.Rows.HeaderCount Then Me.gridDataBoundGrid1.Model.BeginUpdate() Me.gridDataBoundGrid1.CollapseAtRowIndex(row) Me.gridDataBoundGrid1.ExpandAtRowIndex(row) Me.gridDataBoundGrid1.CollapseAtRowIndex(row) Me.gridDataBoundGrid1.ExpandAtRowIndex(row) Me.gridDataBoundGrid1.Model.EndUpdate() End If End If End If End Sub

SY Syl May 13, 2004 10:05 AM UTC

Magnifique! Thanks a lot Super-Clay After some little update to fit in my project, it''s working fine Thanks again! bye syl

Live Chat Icon For mobile
Up arrow icon