PerformWork Event not being triggered

Posts   
 
    
hameedAEM1
User
Posts: 17
Joined: 14-Sep-2006
# Posted on: 29-Sep-2006 13:38:21   

Hi,

I am using Adapter and VS2005.

I have a gridview setup on a page using llblgenprodatasource2. When I load the page the griview binds correctly to the data and everything works fine. LivePersistence = true.

When editing I need to update some values in code. So when user changes say the name field and clicks the update link, I need to add the current date to an UpdateDate field and also the userid of the logged in user.

Now I was performing this in the GridView_RowUpdating event, the updatedate field updated correctly but the userid field was not being updated. I then hooked up the PerformWork event and setup the changes in this event as below:


    protected void LLBLGenProDataSource2_1_PerformWork(object sender, PerformWorkEventArgs2 e)
    {
        // --       
        
        foreach (UnitOfWorkElement2 l in e.Uow.GetEntityElementsToUpdate())
        {
            if (l.Entity.LLBLGenProEntityTypeValue == (int)EntityType.TourOperatorEntity)
            {
                TourOperatorEntity t = (TourOperatorEntity)l.Entity;
                t.UpdatedDate = System.DateTime.Now;
                t.FkuserId = Utility.GetUserId(this);
            }
        }

        e.Uow.Commit(LLBLGenProDataSource2_1.AdapterToUse, true);
    
        LLBLGenProDataSource2_1.Refetch = true;
        CGridView1.DataBind();
    }

In this I am updating the touroperatorentity properties and then commiting the changes.

The problem is that the performwork event is not firing. Now I maybe missing something small.

Regards Hameed.

hameedAEM1
User
Posts: 17
Joined: 14-Sep-2006
# Posted on: 29-Sep-2006 15:38:53   

Hi,

After further testing I found that the entity generation lowercased by property name. And hence in the GridView_RowUpdating event I was typing:

e.NewValues["FKUserID"] = this.GetUserId(this);

where "FKUserID" is the name of my field in the touroprator table. But after code generation it set the property to "FkuserId". After I made the change:

e.NewValues["FkuserId"] = this.GetUserId(this)

it worked fine.

But this still leaves the question why the PerformWork event is not being triggered. Am I missing something?

And also should I be updating the entities in this event or RowUpdating event is Ok.

Hameed.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Sep-2006 17:35:14   

Most probably you are using LivePersistence, and then you should set it to false in the LLBLGenProDataSource declaration.

Please refer to the manual: "Using the generated code -> Adapter / SelfServicing -> Databinding with ASP.NET 2.0"

Read the sections "LivePersistence and events"