BussinesListBase and DatagridView with BindingSource.AllowNew =true

BussinesListBase and DatagridView with BindingSource.AllowNew =true

Old forum URL: forums.lhotka.net/forums/t/6259.aspx


Antonio Sandoval posted on Tuesday, January 27, 2009

Hi, I'm new using CSLA Framework, I have started to use the 3.0 a couple of months ago. I have a little project in wich I need that the user capture the details directly into the datagrid, I have a Root named Document, Detail and a root list DocumentDetails.
+Document <BussinesBase>
    + DocumentDetails <BussinesListBase>
       + Detail <BussinesBase>
              private Detail()       //Private constructor

Everthing works fine when I add new childrens by code. But if try to add news childrens trough the DatagridView I get an error about the constructor (this is private in my library). So, if I change the constructor to public goes fine. I have buyed and readed CSLA .NET Version 2.1 Handbook (C#) and Expert C# 2005 Business Objects books, but I did not find the solution. I have tried with EditableRootListBase and it works!, but each Document is about 30 -50 details, so its preferible to do the update in one batch.

I think that could exist a better solution than have a public constructor.

I'm sorry for my english Stick out tongue [:P]

Thank you

rsbaker0 replied on Tuesday, January 27, 2009

I override AddNewCore() in my BusinessListBase-derived class and call a static factory method I implemented on my child object (e.g. this would be something like detail = Detail.Create() in your model).

Antonio Sandoval replied on Tuesday, January 27, 2009

Ok, that works perfect! thank you Smile [:)]
 Have a nice day.

Copyright (c) Marimer LLC