VB.Net: How to determine if the previous record was modified using the BindingSource?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nev
    Contributor
    • Oct 2007
    • 251

    VB.Net: How to determine if the previous record was modified using the BindingSource?

    Good day to all! I was trying to search the internet about this problem but I still can't seem to stumble upon an answer.

    I am using a BindingSource on my program and everything is ok except that the users can edit any record they want before saving them all in one click. Well, this is fine when doing common saves. But, in my program, I have placed validations for each particular fields.

    When I add or edit a record then save, the validation will be processed thus validating each data in every field. But if I do for example add or edit a record then I'll move to a different record which has been saved before and is valid, when I click save, everything will be saved including the record I added or edited a while ago bypassing any of the validations I made.

    The validations is done on the save button and checks the currently displayed data in each field.

    I was thinking of an OnLeave event of a BindingSource record so that I can manually fire my validations there. So If a user moves to a different record, I must check if the previous record was modified in some sort. If it is, I'll prompt the user "The previous record has been modified, please save that record first to apply changes". So that the user will be required to click the save button that I can perform validations.

    How can this be done? Thank you.
  • nev
    Contributor
    • Oct 2007
    • 251

    #2
    Originally posted by nev
    Good day to all! I was trying to search the internet about this problem but I still can't seem to stumble upon an answer.

    I am using a BindingSource on my program and everything is ok except that the users can edit any record they want before saving them all in one click. Well, this is fine when doing common saves. But, in my program, I have placed validations for each particular fields.

    When I add or edit a record then save, the validation will be processed thus validating each data in every field. But if I do for example add or edit a record then I'll move to a different record which has been saved before and is valid, when I click save, everything will be saved including the record I added or edited a while ago bypassing any of the validations I made.

    The validations is done on the save button and checks the currently displayed data in each field.

    I was thinking of an OnLeave event of a BindingSource record so that I can manually fire my validations there. So If a user moves to a different record, I must check if the previous record was modified in some sort. If it is, I'll prompt the user "The previous record has been modified, please save that record first to apply changes". So that the user will be required to click the save button that I can perform validations.

    How can this be done? Thank you.
    Hi just to help others out, what I currently do which works is to iterate each record by assigning each to a datarow then I can check

    if datarow.rowstat e = rowstate.modifi ed then
    'place code here
    end if

    hope this helps anyone

    Comment

    Working...