How do I set the SelectMethod?

How do I set the SelectMethod?

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


Greg posted on Friday, August 24, 2007

ObjectDataSource has a SelectMethod which is used to retrieve data to populate a gridview. For the CslaDataSource, I have the TypeAssemblyName and TypeName set but I see no property to supply the SelectMethod. What is the Csla equivalent property for the SelectMethod in the Visual Studio 2005 Properties window?

In the book, I see an OnSelectObject in the Source view for an aspx page. When I place the SelectMethod in the OnSelectObject parameter I get a build error that the page " does not contain the definition".

Basically, I have the gridview filling nicely when I use ObjectDataSource and now want to get it working with the CslaDataSource control but cannot see how to set up the SelectMethod.

 

RockfordLhotka replied on Friday, August 24, 2007

This is a standard event model, so the method name you provide on the <csla:CslaDataSource> tag corresponds to an event handler in your code.

Or if you are using VB it is a method with a Handles clause rather than linked from the markup - but again, a standard event handler.

RockfordLhotka replied on Friday, August 24, 2007

I guess I could provide some explaination - though it is in the book too, but back in the chapter discussing how/why CslaDataSource exists, rather than in Chapter 10 where it is used.

The ObjectDataSource uses reflection to invoke the method names you provide. That's OK, but is an odd model because it is unlike virtually every previous model. And of course it uses reflection, which is an iffy proposition for some people. But my biggest objection, is that it presupposes that you have TWO objects - the actual business/data object and another object to do the CRUD operations.

ODS is designed to support the DataSet, and so this makes sense, since the CRUD operations are managed by a TableAdapter. They have that separation.

CSLA objects are more abstract and more encapsulated, so you don't typically have a CRUD object like the TableAdapter. I thought about making you create one for every object-page combination, but that seemed silly to me.

So CslaDataSource uses a more traditional (and imo more standard) event-drven model. This avoids reflection, provides better debugging and avoids the need to create a CRUD object in addition to your page. Instead, the "methods" are just event handlers in the page itself, so you can use normal coding conventions to handle them - just like you would with events from any other control on a page.

Copyright (c) Marimer LLC