ERLB - How to get selected record refreshed from the database

ERLB - How to get selected record refreshed from the database

Old forum URL: forums.lhotka.net/forums/t/8088.aspx


jetta posted on Thursday, December 03, 2009

Hi There,

How can we refresh a single row on the datagrid which was binded to ERLB of BusinessBase child object. We have to refresh the datagrid row showing any latest changes from the database just before record is entering into edit mode. Is there any way we can do this either at ERLB end or BB level? Please let me know.

Thanks Regards

ajj3085 replied on Friday, December 04, 2009

Well your BB object contained within the ERLB instance should be a root object.  You might be able to add a refersh method to the BB class, which would update all your properties and then send an unknown propertychanged.  I think it could work in theory at least..

jetta replied on Monday, December 07, 2009

Thanks for the reply ajj3085. This is so helpful! I will implement this and let you know.

jetta replied on Friday, December 18, 2009

Thanks again ajj3085, I have implemented this approach works well. Here is my code snippet,

    Public Sub Refresh()
        Me.DoRefresh()
    End Sub

    Private Sub DoRefresh()
          'Get most recent data from the db.
          'Dont use Me.BypassPropertyChecks here
          'Populate BB properties with latest data from db.
    End Sub

Best Regards

mbblum replied on Sunday, December 20, 2009

Word of caution! This looks like it is not using dataportal for db access. Result can be client accessing database directly for the refresh, even if you move the rest to 3-tier.

ajj3085 replied on Monday, December 21, 2009

Well the idea of the Refersh method on the BB subclass would be that it internally uses a command object to use as a DTO, which includes using the dataportal to fetch the relevent data, and then update itself.

so your refresh would look like this:

public void Refresh() {

   var getLatestDataCmd = DataPortal.Execute<DataCmd>( new DataCmd( myId ) );

   // update properties here

}

Copyright (c) Marimer LLC