[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

Get Datatable Changes

Hello Experts,

I have a web application that shows data from a table in a grid.  It uses a Select * query to fill a datatable. Then I populate my grid using the datatable.  I want a user to be able to edit/change the data in the grid.  After editing the data I want to be able to retrieve just the rows of data from the grid that the user made changes to.  The changed rows will then fill a seperate Datatable which I need for a specific function.  
How can this been accompished ?  

1 Solution
Wayne Taylor (webtubbs)Commented:
Hi straucha,

Use GetChanges....

    Dim ChangedRows As DataTable = myDataTable.GetChanges()


strauchaAuthor Commented:
I would love to use the getchanges method but I am having trouble with it.  Let me give you my code.
Step 1...Fill the Datatable for the first time

    Public Shared newDt As DataTable

   Private Sub FillGrid()   ' Set off by a button
        Dim Selstr As String = "Select * from ProdCat"
        newDt = GetMvTable(Selstr)    ' Fills the Datatable for the first time
        FpSpread1.DataSource = newDt      ' Sets the data in the Datatable newdt to the Grid
    End Sub

Step 2......User has made the Changes to the datatable in the grid so save those changes

Public Sub SaveData()   ' Kicked off by a button
Fpspread1.savechanges()       'Save the changes of the grid

newdt = fpspread1.datasource()   ' Reset the Datatable NewDt to the user changes
end sub

Step 3 ......Show just the changed rows

  Dim ChangedRows As DataTable = newDt.GetChanges()      ' This is not finding anything at this point
        FpSpread1.DataSource = ChangedRows

I do not want to use a datatset in my code....any suggestions

  Dim ChangedRows As DataTable = newDt.GetChanges()      ' This is not finding anything at this point

It won't.  When you called


it reset all the rows' .RowState flags to Unchanged.


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now