[Serializable()] public class AList : BusinessListBase<AList, A>
{
public AList()
{
MarkAsChild();
}
}
[Serializable()] public class A : BusinessBase<A>
{
}
aspx.cs
objectAInstantiatedList[index].Delete();
GrdTest.DataSource = objectAInstantiatedList;
GrdTest.DataBind();
The objectAInstantiatedList has 3 records and once i delete the item.. the objectAInstantiatedList is not updating the count to 2 and the grid still showing 3 records. Please suggest where am going wrong..
To delete a child object in a list, you call Remove on the list, not delete on the child.
Thanks for reply Lhotka.. But if i use remove then it throws error saying use delete instead and thats the reason i used delete.
objectAInstantiatedList.RemoveAt(index);
GrdTest.DataSource = objectAInstantiatedList;
GrdTest.DataBind();
If your child object is actually a child object, then calling Delete() should cause an exception.
So your problem is probably that your "child" objects are not being created as child objects (you aren't using the child data portal, or calling MarkAsChild()).
If you are using any reasonably modern version of CSLA (3.5 or higher) you should consider using the child data portal, because that takes care of these details for you.
Thanks for the reply. You are correct.. A is Businessbase and Alist is BusinessListBase
public class A : BusinessBase<A>
public class AList : BusinessListBase<AList, A>
I created a factory method DeleteA in A which calls DataPortal_Delete()
The objectAInstantiatedList[index].Delete() wont work like you explained. But how will the A's Portal delete know that it has to delete from objectAInstantiatedList object.
Have you read Expert 2008 Business Objects chapters 1-5 and 17-18? I strongly recommend reading or rereading those chapters, as they explain pretty completely how this all fits together.
I have read the chapters and that clears some of my questions.You are correct the child objects am talking is not actually a child object. 'A' is a businessbase and Alist is business list base. So 'A' is a parent and i cant remove a parent using remove. I can delete that using dataportaldelete but the thing is that will actually delete from the database with some criteria as parameters. But the situation here is... user will keep on adding A's to Alist manually and they are in session memory. So when i use dataportal delete i cant really delete it from Alist as its not saving to database. Please suggest...
Copyright (c) Marimer LLC