Results 1 to 2 of 2

Thread: [RESOLVED] Set datarow rowstate after table.ImportRow()

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Resolved [RESOLVED] Set datarow rowstate after table.ImportRow()

    Hi Guys,

    I drag and drop datarows from a grid to a treeview. Then I try to change the rowstate of the dropped rows.

    Code:
    Private Sub gclevels_DragDrop(sender As Object, e As DragEventArgs) Handles gclevels.DragDrop
            Dim grid As GridControl = CType(sender, GridControl)
    
            Dim table As DataTable = CType(grid.DataSource, DataTable)
    
            Dim rows() As DataRow = TryCast(e.Data.GetData(GetType(DataRow())), DataRow())
    
            If Not rows Is Nothing And Not table Is Nothing Then
    
                For Each row As DataRow In rows
                    table.ImportRow(row)
                Next
    
                table.AcceptChanges()
                Dim testforchanges As DataTable = table.GetChanges(DataRowState.Unchanged)
    
                If testforchanges IsNot Nothing Then
    
                    For Each newrow As DataRow In testforchanges.Rows
                        newrow.SetAdded()
                    Next
                End If
    
            End If
    
        End Sub
    This works. However, when I try to get the changes in the datatable on the click of my save button I get nothing

    Code:
     Dim dt As DataTable = TryCast(grid.DataSource, DataTable)
    
                            If dt.Rows.Count > 0 Then
                                Dim testdt As DataTable = dt.GetChanges(DataRowState.Added)
                            End If
    Please help me fix this

  2. #2

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Set datarow rowstate after table.ImportRow()

    no worries. I found the problem. I removed the table.acceptchanges call.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width