Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2430
Simple Question of how to add rows
posted

I have a WinGrid that is bound to a BindingSource and it hooks up tio Oracle database.  It has 8 bands (aka 7 child tables hooked together w/ relations).

I have a request to duplicate the current record (aka duplicate all bands beneath the current record) and thus change the keys to make a unique primary key.

I can manually add to the table adapter which adds to the database but when I call Grid.Update(), it doesn't show the newly created record.  I figured the best way was to add to the grid and then get the DataRow from there and push into the database.  The problem is I do not see the easy calls to do this.

UltraGridRow newFMECARow = FMECAGrid.DisplayLayout.Bands[2].AddNew();

This causes the row editor (aka template editor to fire).  I want to pass it the new row (aka, let me fill it in and remove the user interaction (I want to pass a new UltraGrid row to addnew).

I would like to do something like the following:

UltraGridRow newFMECARow = FMECAGrid.DisplayLayout.Bands[2].AddNew();

newFMECARow.Cells["OBJECT_TYPE"].Value = FMECAGrid.ActiveRow.Cells["OBJECT_TYPE"].Value;

newFMECARow.Cells["TECHNOLOGY_TYPE"].Value = FMECAGrid.ActiveRow.Cells["TECHNOLOGY_TYPE"].Value;

newFMECARow.Cells["TITLE"].Value = FMECAGrid.ActiveRow.Cells["TITLE"].Value;

newFMECARow.Cells["DOCUMENT_NO"].Value = "Copy of" + FMECAGrid.ActiveRow.Cells["DOCUMENT_NO"].Value;

newFMECARow.Cells["LAST_MODIFIED_BY"].Value = WindowsIdentity.GetCurrent().Name;

newFMECARow.Cells["LAST_MODIFIED_DATE"].Value = DateTime.Now;

FMECAGrid.ActiveRow = newFMECARow;

Is there a way of doing this easily - looked at samples and it wasn't exactly clear how to do but it must be doable.