Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Adding Records to a Dataset
I have an issue and a question. My application uses an XML database and is having a problem adding and saving records. A new record is created by getting a new row from the existing dataset and then immediately adding the row to the dataset's table collection and accepting the changes. At this point I would expect the row to have an index/count of n+1; it doesn't and will generate an error if accessed as n+1. Then, since the dataset is bound to a datagrid/datview on the UI, the record at position n+1 is displayed for the user to make changes.
Now the problem. The record displayed is not the new one. I've a few different things including sorting the data to force the dataview to place the new record at the end of the dataset where I expect it. This doesn't work. How do I get this to work? An easier approach would be to make my changes to the new record before it is added to the dataset, but that presents problems due to the architecture of the app.