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

x
  • 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 ?  




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

Use GetChanges....

    Dim ChangedRows As DataTable = myDataTable.GetChanges()

Regards,

Wayne
0
 
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
 newDt.AcceptChanges()
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



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

It won't.  When you called

 newDt.AcceptChanges()

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

Roger
0

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