CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

CslaDataSource with ASP.NET Step Wizard

rated by 0 users
This post has 6 Replies | 2 Followers

Top 25 Contributor
Posts 199
decius Posted: Mon, Jun 9 2008 3:59 PM

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. 

 

-Mark
Top 10 Contributor
Posts 9,269

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.

Rocky

Top 25 Contributor
Posts 199
decius replied on Tue, Jun 10 2008 7:33 AM

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?

 

-Mark
Top 75 Contributor
Posts 106
griff replied on Tue, Jun 10 2008 7:56 AM

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

 

 

Top 25 Contributor
Posts 199
decius replied on Tue, Jun 10 2008 9:09 AM
fabulous! That was just what I was looking for. Thanks a million.
-Mark
Not Ranked
Posts 1
Thanks a lot.. It helped me at right time...
Top 200 Contributor
Posts 41
vbbeta replied on Thu, Apr 19 2012 4:29 PM

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

Page 1 of 1 (7 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems