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
400
Set already created object on new row
posted

Hi!

I have an editable grid that allows new rows. The grid is bound to an EntityCollection<MyEntity> of entity framework. By default the grid initializes a new instance of MyEntity when the user clicks on the new row. What I want to do is to create that instance myself using my own code and then provide that instance to the grid.

Is this possible?

Parents
No Data
Reply
  • 37774
    posted

    Whether you can do this or not depends on the amount of control that you have with your data source.  The grid will use the .NET BindingManager's AddNew method if you are using an IBindingList (I'm not familiar with EntityCollection<T>), which will call the AddNew method on the IBindingList, so I guess you could trap whether you're between the BeforeRowInsert and AfterRowInsert events of the grid and return a new row of your own choosing at that point.  Since adding isn't generally supported without an IBindingList, I'm assuming that this approach applies to your implementation.

    -Matt

Children
No Data