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
340
adding new rows to a grid that is databound to an array of dto objects
posted

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?

Parents
  • 469350
    Offline posted

    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.

Reply Children