Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27412

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

$
0
0
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

Viewing all articles
Browse latest Browse all 27412


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>