Setting up CSLA databinding on a webpage using an @Register tag

Setting up databinding using a custom datasource within a page is not always obvious.  I'm putting this on my blog as I know I'll be referring back to it.

CSLA is available on Rocky Lhotka's site with downloads, forums and latest version info.

Because databinding is provided through the generic CslaDataSource object in the CSLA framework, there's a bit of indirection going on in the setup.  Rocky's sample code in ProjectTracker defines the page level references in the web.config file, but I'd rather explicity define them on the page for now.

First, register the Csla assembly in the @ Register tag at the top of your aspx file with:

 <%@ Register Assembly="Csla" Namespace="Csla.Web" TagPrefix="csla"  %>

This allows for a reference to the datasource provider in the framework.

Next, define the actual datasource object on your page that references your business object/collection using the following:

 <csla:CslaDataSource ID="MyDataSource" runat="server" 
     TypeAssemblyName="[Assembly Name that implements TypeName]"
     TypeSupportsSorting="False" >

You'll need to wire up the OnSelect and other handlers, but Rocky's book provides excellent examples of this.

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply