Set default values when created by databound control

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 18-Mar-2009 19:04:50   

I have a customer entity with a country field.

When the user uses the datagrid to add a new customer I want the country to default to Canada.

Currently I do this in the datagrids' event structure and manually assign the value.

Is there a more appropriate override I can use in the customerEntity itself to do this defaulting?

Ian

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Mar-2009 05:45:37   

**OnInitialized **is your answer. You can do this on a partial class or at USER_CODE_REGIONS:

namespace MyNamespace.EntityClasses
{
    public partial class CustomerEntity
    {
        protected override void OnInitialized()
        {
            base.OnInitialized();

            // this is canada
            this.CountryId = 1;
        }
    }
}
David Elizondo | LLBLGen Support Team