Need help to update data

Need help to update data

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


amit posted on Monday, December 31, 2007

Hi All..
I am a new to the CSLA,,,and trying to write code for updating the data..but I don't want to  use any data binding (csla data source). I want to take values from text box and call save() method
as

 object objProjectListName = MyApp_Bo.ProjectList.GetProjectListName(txtName.Text);     

((MyApp_Bo.ProjectList)(objProjectListName)).Id = new Guid();

((MyApp_Bo.ProjectList)(objProjectListName)).Name = txtName.Text;

((MyApp_Bo.ProjectList)(objProjectListName)).Description = txtDesc.Text;

((MyApp_Bo.ProjectList)(objProjectListName)).ApplyEdit();

((MyApp_Bo.ProjectList)(objProjectListName)).Save();

but when I  run this code it executes DataPortal_Insert() method rather than DataPortal_Update() method, I think it is due to IsDirty is always set to false.

can anybody pls help me..

 

ajj3085 replied on Monday, December 31, 2007

What does your GetProjectListName and DataPortal_Fetch look like? 

JoeFallon1 replied on Monday, December 31, 2007

It will run the Isert if the object IsNew. It will do the Update when IsNew=False.

When you fetch the BO you should call MarkOld as one of the last steps.

You may be creating a new BO in your DP_Fetch which does not follow the standard pattern.

Joe

 

Copyright (c) Marimer LLC