I am adding data directly to an UltraGrid through a templateAddRow. When I click into the template row, and click back to a previously added row, it 'cancels' the new template row, but it also removes the first newly added row. Like.. from the top of the grid. This makes no sense to me. Am I doing something wrong?
Hi,
Obviously, that's not desirable or correct behavior. My guess is that there isn't actually any way via IBindingList to cancel just a single row, so the grid is probably telling the data source to cancel all pending changes and for some reason, your first row has not been committed.
How are you adding the first row? If you are doing it through the grid, then that row should be committed as soon as you leave the row. Unless you changed the UpdateMode property on the grid so that it does not do that.
My best guess is that you are adding that row in code and not committing it.
What kind of data source are you using? And how are you adding that row?
If you are using a DataTable/DataSet, you might have to call CommitChanges after you add the row so it gets committed.
The data source is a Csla BusinessListBase. I struggled to get the template row function to work, but it was because the object did not have a public parameterless constructor. Now the template row works, but it is not committing. I have not changed the update fuction. I was adding the row through the template add row.
If I call AddRow() from the BusinessListBase, it works fine, so I think I'll leave it at that. I'm tired of messing with this.
I'm not familiar with the Csla classes, but I imagine this is probably something similar to the first issue. The grid or the BindingManager is probably telling the data source to commit the change and either the method it needs is not public, or does not exist, or just isn't working correctly.
You're welcome. Sorry I couldn't tell you exactly what's going on there, but at least you got it working. :)
Sorry.. I meant to infer that. I am using a BindingSource. It's bound to a rather large object, which also contains the BindingListBase filled with items. The grid is bound to the 'Items' property of the BindingSource.
The weird thing is, I'm working on a project written by someone else, and they do have a working model of what I am trying to accomplish. I have spent far too long trying to replicate what he has going on, but it's just too complicated to follow every little piece. He is using the same approach, but apparently something is still out of place. Unless I run into other issues, I will work with what I have.
Thank you for your time and help. I see you around here a lot, and you help a lot of people. So thank you on behalf of them too :)
BTW... I understand that you have a workaround and don't want to spend any more time on this, but one very quick and easy thing you might try is to use a BindingSource. Sometimes the BindingSource handles these kinds of issues for you. You basically just bind the BindingSource to your data source and then bind the grid to the BindingSource and it acts as a sort've intermediary and sometimes it handles issues like this.
Just a suggestion.