ASP.Net DataBinding Question

ASP.Net DataBinding Question

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


SouthSpawn posted on Monday, October 26, 2009

Ok,
 
I have an object that is like the following.
 
Person.Profile.BusinessTypes ("LIST" of "Editable Childs")
 
So basically.
 
Person = Editable (Parent)
 
Profile is EditableChild or Parent Person
 
BusinessTypes is Collection of Editable Childs of parent Profile.
============================================
I have an asp.net form with a CSLA Datasource on it.

I also have a asp.net "CheckBoxList" control on the page.
 
In code, I am doing the following.
 
MyCheckBoxList.DataSource = Person.Profile.BusinessTypes;
MyCheckBoxList.DataBind();
 
This works no problem.
Here is my question.

Since the CheckBoxList will allow the users to selected multiple.

What is the "Proper" way to update the "EditChildCollection" of objects during the CSLA_DataSource_Update event?

Do I have to do the following.
 
Person = Person.GetPerson(Id)
 
int counter = 0;
 
foreach(myItem in CheckBoxList.Items)
{
      Person.Profile.BusinessTypes[counter].Active = myItem.checked;

      counter += 1;
}
 
person = person.Save();

I could do this, but for some reason, I am thinking it should automatically do it for me?

What am I missing here?

Copyright (c) Marimer LLC