Results 1 to 3 of 3

Thread: Question about editing a DataGridView

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Question about editing a DataGridView

    I am using a DGV to display data from a table & allow the user to edit individual cells & then click a Save button to update the table. When the user clicks the Save button I show a Yes/No MessageBox that confirms the user really wants to write the edits. If they click Yes, the update is called & that part works fine. But if they click No, then I want all the cells that were edited to revert back to their original values. How can I achieve this? BTW, the DGV is bound to a DataTable.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Question about editing a DataGridView

    Call RejectChanges method of the datatable or datarow if the user click No. However, you must make sure that you call datatable.AcceptChanges before any editing occurs, and after updating data to the database.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Question about editing a DataGridView

    Thanks stanav ... that worked.

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