StrataFrame Forum

Data is not save from editable Grid

http://forum.strataframe.net/Topic8997.aspx

By Joseph-Carl Theodat - 5/23/2007

Hi,

The following code is used to save the data from and editable grid which has a BusinessBindingsource.CurrentTable as the datasource.

private void tsSave_Click(object sender, EventArgs e)

{

bool ok = false;

MicroFour.StrataFrame.Data.SaveUndoResult saveStatus;

try

{

//Start the transaction

BusinessLayer.TransactionBegin("", System.Data.IsolationLevel.ReadCommitted);

saveStatus = propositionVersionBO.Save(true);

if (saveStatus == MicroFour.StrataFrame.Data.SaveUndoResult.Success)

{

if (propositionDetailBO.IsDirty)

if (propositionDetailBO.Save(true) == MicroFour.StrataFrame.Data.SaveUndoResult.Success)

ok = true;

}

}

catch (Exception)

{ // Not supposed to happen

// Write to Log entity

}

finally

{

if (ok)

{

// Everything succeeds, so it's time to commit

BusinessLayer.TransactionCommit("");

dgPropositionVersion.EditMode = DataGridViewEditMode.EditProgrammatically;

tsSave.Enabled = false;

tsUndo.Enabled = false;

tsEdit.Enabled = true;

}

else

{

// Error occurs, so rollback

BusinessLayer.TransactionRollback("");

// Keep business objects in edit mode

Edit();

}

}

}

For some reason the the after the commit, the primaryBO (not using grid) is updated but the other one (propositionDetailBO using grid) is not. What's wrong? I cant see the grid has the previous values after the commit... Without having the devexpress grid, is it possible to have an editable grid from the 2.0 framework to work with the BO?... If not do you have any plan to resolve the issue...

P.S

Sorry for the code indentation (cut & paste)

By StrataFrame Team - 5/23/2007

Does the propositionDetailBO still think it's dirty after the save (propositionDetailBO.IsDirty == true)?  And how exactly do you have the DataSource on the grid configured?  Did you set the CurrentDataTable as the data source directly, or did you set the BusinessBindingSource as the data source directly and set the BusinessObject property on the BBS to the propositionDetailBO?
By Joseph-Carl Theodat - 5/23/2007

it will simpler to know if it is possible to save date from an editable grid using the BO. If yes, how?
By Joseph-Carl Theodat - 5/23/2007

My code works! I forgot to exit the cell of the grid in order to accept the changesBigGrin

Hope that my code can help...

By StrataFrame Team - 5/24/2007

Hehe, yes, it is possible to save the data from the grid.  But like you said in your post above, most grids make you edit the editing cell to comitt the data back to the data source.