Newbie, Howto use Csla.Data.DataMapper.Map correctly?

Newbie, Howto use Csla.Data.DataMapper.Map correctly?

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


NickyLarson posted on Monday, February 28, 2011

Hi everyone,

 

This maybe a silly question but , i don´t know how to use correctly the  Csla.Data.DataMapper.Map

In the ProjectTracker, use CslaDataSource binding to a DetailsView and then can operate do to insert , delete, update.

Exe the update in the ProjectEdit.aspx

    protected void ProjectDataSource_UpdateObject(object sender, Csla.Web.UpdateObjectArgs e)
    {
      Project obj = GetProject();
      Csla.Data.DataMapper.Map(e.Values, obj);
      e.RowsAffected = SaveProject(obj);
    }

here all the object of type Project are in the e.Values and then mapped to the obj of type Project.

Now my question is, I have a form with 2 text box and they aren´t binding with none CslaDataSource. How can I use Csla.Data.DataMapper.Map in this situation. I have done like this but i am not sure if it´s the best or the correctly way to do this.

 

private int updateField()

{

       Project obj = GetProject();

      obj.name= this.textboxName.text;

      obj.address= this.textboxAddress.text;     

      return SaveProject(obj);

}

 

Like a say i am newbie maybe some of you can laugh but i am still learning.

 

Thanks in advance

 

NickyLarson.

 

 

 

ajj3085 replied on Monday, February 28, 2011

The datamapper is really meant to work as you have shown in your first code snippit; its goal is to help support two way databinding in Asp.Net.  If you're not using two way databinding, then the second method you have shown is how you would acomplish updating the BO.

NickyLarson replied on Tuesday, March 01, 2011

Hi Andy,

 

Thank you for the reply, you help me a lot, You dispelled my doubts.

NickyLarson

Copyright (c) Marimer LLC