Get Datatable Changes

Posted on 2007-08-02
Last Modified: 2012-06-27
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 ?  

Question by:straucha
    LVL 46

    Expert Comment

    by:Wayne Taylor (webtubbs)
    Hi straucha,

    Use GetChanges....

        Dim ChangedRows As DataTable = myDataTable.GetChanges()


    LVL 1

    Author Comment

    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

    LVL 34

    Accepted Solution

      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 Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now