CslaDataSource to supply Friendly / Display name to GridView when Refresh Schema is performed

CslaDataSource to supply Friendly / Display name to GridView when Refresh Schema is performed

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


Jaans posted on Thursday, March 12, 2009

This is one for the wishlist.

I'm aware of the difficulty in having the new Csla PropertyInfo object provide the same functionality as the System.ComponentModel.DisplayNameAttribute does.

We generate our properties, so for us we workaround the issue by repeating the Friendly Name value for the DisplayName attribute. It does the job as needed in Windows Forms application binding.

Is it possible for the CslaDataSource web control be enhanced to take the either the FriendlyName DisplayName information and provide it to the binding target? It would further reduce developer effort and UI customization that would be duplicately defined in the BO.

Put differently I would like to see the following:

  1. Csla Business Object with managed properties using the PropertyInfo technique. Specify the Friendly Name for each.

    OR

    Adorn properties with with the DisplayName attribute.
  2. Drop a CslaDataSource web control on a web page and hook it up to the above business object.
  3. Drop a GridView control and hook it up to the above CslaDataSource web control, upon which Schema Information is provided by the CslaDataSource control to the GridView to define column names, etc.

    Part of this process I would like to see the Friendly Name / Display Name be used for the columns' Header Text.

This would save the developer from needing to know and specify what friendly name to use for the column.

Many thanks,

Jaans

RockfordLhotka replied on Thursday, March 12, 2009

Does the GridView control pick up the DisplayName attribute value automatically?

Certainly the new lambda expression scheme for RegisterProperty() in 3.6.2 makes it much more realistic to think about grabbing the DisplayName attribute value to use as the CSLA friendly name.

Jaans replied on Tuesday, March 17, 2009

Hi Rocky

Well that's the question really. The CslaDataSource control sits between the GridView and the business object and I'm not sure whether there is any "infrastructure" in the web design environment for a GridView control to read such schema / metadata information for each property.

I can confirm that it currently doesn't automatically flow extra metadata through the CslaDataSource. I have placed a DisplayName attribute onto a business object property and subsequently connected a CslaDataSource control followed by a GridView and the HeaderText for a column was unnaffected.

This is exactly what I would like to see. Specify either a FriendlyName/DisplayName for a business object property and then (when bound on the web through a CslaDataSource property at design time), it automatically sets the HeaderText for GridView/DetailsView/etc. controls. Very much in the same way a Grid control does in the Windows Forms environment.

Is that possible?

Regarding the lambda expression - Yes indeed, using the 3.6.2 lambda expression would indeed be the preferred way to set the DisplayName attribute value

Again, many thanks

J

RockfordLhotka replied on Tuesday, March 17, 2009

I suspected it wouldn’t be automatic, but didn’t know for sure.

 

Certainly at design time it wouldn’t be automatic – the gridview (and other controls) get their design time information from the CslaDataSource design time behaviors, which is a whole subsystem beneath the data source control itself. It may be possible to enhance those behaviors to look for the DisplayName attribute and/or to use the friendly name value – though it depends on whether the data binding infrastructure has a placeholder for a friendly name value.

 

I can’t say off the top of my head, as I haven’t looked at the data source code for a couple years. If there’s a data binding placeholder for a friendly name it would be easy enough to do – but if there is such a placeholder, then I’m a little surprised that I didn’t use it properly in the first place…

 

I’ve added a wish list item for this

http://www.lhotka.net/cslabugs/edit_bug.aspx?id=371

 

Rocky

Copyright (c) Marimer LLC