I have done a testproject of a N-tier application where I have a Windows Forms Project using a WCF Plain service.
I have a form with a Toolbar and a Grid. In Form_Load call the WCF Service and fetch the data I want to display in the grid.
The service returns the data as an Array of dto objecs. I set the grids datasource to that Array and the data displays fine.
I then want to add a new row to the grid and save it back to the database.
Previously when I worked with ADO.NET Datatables I could use .Displaylayout.Bands(0).AddNew() on the grid.
When I tried this I got an error saying that it isn't allowed for this type of datasource.
How do I do Inserts and deletes when the grid is databound to an Array of dtos?
Hi,
You can't add items to an array. This is nothing to do with the grid, the Array simply doesn't support it. What I would do is create a BindingList<T> and populate it with the contents of your array and then using the BindingList as your grid's DataSource. BindingList supports all of the usual binding operations like adding and deleting.
I'll look into that.
I wish that my WCF Service that was autogenerated by a wizard had methods that used a BindingList instead of an Array.
For now I'll have to find/write examples that does the convert back and forth.