CslaDataSource with ASP.NET Step Wizard

CslaDataSource with ASP.NET Step Wizard

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


decius posted on Monday, June 09, 2008

I'm new to CSLA and am really struggling with this. I'm wanting to derive a nice way of using an ASP.NET step wizard alongside the CslaDataSource. I've searched hard through the forums, but no one else must be having such a hard time like me ;P

No matter what I keep running into a wall trying to do this and I always end up throwing a bunch of convoluted code in to get it to do what it needs to.

I keep wanting to be able to call the UpdateObject event when the user clicks the Next button on the wizard, but I can't figure out how I can pass it the UpdateEventArgs object easily...  Any help or suggestion is greatly appreciated. 

 

RockfordLhotka replied on Monday, June 09, 2008

I haven't tried this, so I don't know the answer.

However, the CslaDataSource works exactly like any other data source control. So whatever technique would be used to trigger the event on, for example, ObjectDataSource will work on CslaDataSource.

In any normal scenario you don't raise the event. Instead, you interact with a visual control (like the GridView or DetailsView) and that control raises the event through the data binding infrastructure.

I don't know that you can raise the event directly. I've never seen anyone do it, and I don't think it is a supported concept when programming against any data source control.

decius replied on Tuesday, June 10, 2008

Thanks for the quick response, Lhotka.

Yes, what I've tried so far is to place separate DetailsView in each step that is connected to the same CslaDataSource. Then I bound the fields related to each step to the appropriate DetailsView.

Ideally I wanted to invoke the UpdateObject event when the user clicks the 'next' button, but am realizing how difficult this might be. Then I figured I could just hide that button and place navigation logic in the "update" button for the details view (essentially turning it into the 'next' button for the wizard). This concept seems sloppy to me, as it nearly defeats the point of using a StepWizard.

Is it at all possible to build an UpdateObjectArgs object from another control and somehow use it to invoke the UpdateObject event?

Maybe using a multiview to streamline a Wizard-Step process might be the way to go... Is this the typical convention that most people use?

 

griff replied on Tuesday, June 10, 2008

Hi

I do this, without any issues e.g.

Protected Sub Wizard1_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick

Select Case e.CurrentStepIndex

Case Is = 0

Case Is = 1

fv1.UpdateItem(False)

Case Is = 2

fv2.UpdateItem(False)

Case Else

End Select

End Sub

fv1 is a formsview

The event  fv1.UpdateItem(False) calls the cslads_Q1 update event (the csla data source object)

Protected Sub cslads_Q1_UpdateObject(ByVal sender As Object, ByVal e As Csla.Web.UpdateObjectArgs) Handles cslads_Q1.UpdateObject

Dim obj As Q1 = GetQ1()

Csla.Data.DataMapper.Map(e.Values, obj, True)

e.RowsAffected = Save(obj)

End Sub

 

Not sure if this helps.

Richard

 

 

decius replied on Tuesday, June 10, 2008

fabulous! That was just what I was looking for. Thanks a million.

thiru_forever replied on Thursday, January 22, 2009

Thanks a lot.. It helped me at right time...

vbbeta replied on Thursday, April 19, 2012

Hi guys i had the same problem but it did not work in total here is my problem the dataSource  triggers the save method but it does not change the object status (isNew- IsDirty) etc unless i'm calling the save strait from the asp form

Copyright (c) Marimer LLC