I'm using the NetAdvantage 8.1 grid in C# 3.5.
The problem I am having is when I am using an ultragrid as a subform. I have my parent record on the main form, and have an ultragrid on that form with its datasource set to a foreign key of that parent record. I'm looking to enter the parent record in the main form, and then have child the record in the grid connected by the primary key of that parent record.
When I have an existing parent record, I have no issues. However, when I generate a new parent record, the child record does not save for that parent.
When I replace the ultragrid with the standard .NET grid, I get the functionality I need. I can add a new parent record, add a child record associated with that record, and the TableAdapterManager.UpdateAll takes care of everything just fine. However, with the ultragrid I am having no luck at all. (I should also point out that not using the TableAdapterManager, but instead manually using the update methods for each adapter doesn't work for me either when using the ultragrid.)
I feel as if I must be missing something simple. Is there a difference in the way you would enter new parent and child records and apply them to the underlying database between the ultragrid and the .NET grid?
Sure.
First of all, it seems that you simply cannot do this if you have Access as your database so I moved all of my tables over to SQL.
To get the identity seed to be able to fill, go to your dataset, right click and choose configure, and then click on Advanced Options. Makes sure the Refresh the Data Table option is checked.
Now go to your form where you are using the datagrid as subform and choose the binding source for that grid. Add some code to its AddingNew event that will end the editing of the main table you want to return a identity seed from.
private void tblEmployeeCommunicationsBindingSource_AddingNew(object sender, AddingNewEventArgs e) { this.tblEmployeeInfoBindingSource.EndEdit(); this.tblEmployeeInfoTableAdapter.Update(this.frostTimeTrackingDataSet.tblEmployeeInfo); }
Now, when you start to add a new row in your grid, your main table will update and fill in the Id to the child record automatically assuming you have the table relations set up.
Let me know if you need anything else.
Can you please post the solution as I am having the same issue.
Thanks in advance
It turned out that this was not a wingrid issue.
Anybody?