How to populate tableEntity prior to Validation & Save

Posts   
 
    
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 18-Oct-2007 03:01:47   

Hi, Simple question. I'm Using Ver 2.0, Adapter, VB.

My form has some text boxes and is used for entry of new data only, so nothing is fetched on Form load. When the Save button is clicked I need to validate the contents of the Form and if valid Save the data.

But as tableEntity does not yet contain the data sitting in the text boxes, how do I populate the underlying tableEntity, prior to my validation?

Do I do this manually, i.e. for each control or have I missed something confused

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Oct-2007 08:22:55   

Hi Markiemac,

You could auto-fill the tableEntity by databinding or by create the tableEntity at Save button click. Then call adapter.Save(tableEntity) and let the validator do its work, using LLBLGenPro ValidatorClasses.

David Elizondo | LLBLGen Support Team
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 18-Oct-2007 11:04:53   

Hi daelmo,

create the tableEntity at Save button click.

  1. Do you mean manually as I would do in:
        Dim tEntity As New TableEntity
        tEntity.RCode = Me.txtRCode.Text
        tEntity.RName = Me.txtRName.Text
        ..etc

As the above could be quite tedious, especially if checking for Null entries, I was interested in any auto methods.

You could auto-fill the tableEntity by databinding

  1. As the controls were bound to tableEntity via the BindingSource at design time, I am not clear what you mean here. Could you explain?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Oct-2007 11:29:02   

You may bind a property of a control to a property of the entity as follows:

countryTextBox.DataBindings.Add("Text", _customer, "Country");