Web Databinding to a Collection without it Looking like a Collection

Web Databinding to a Collection without it Looking like a Collection

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


JonStonecash posted on Wednesday, November 26, 2008

I am looking for some advice on how to display a collection of values without it looking like a collection.  I am building a VS2008 web application using the latest CSLA release.  Some of the business classes have the possibility of being extended to add additional values.  The exact set of extended values differs for each client but does not differ within a client.  What I would like to do is to have these extended values for "Order" show up on the "Edit a Single Order" as if they were regular properties. 

The extended properties exist in two tables (separate from but shared by all tables that can be extended): one holds the actual extended value (in the form a string) and the links to the table row being extended and to a second table.  This second table holds the descriptive data for the extended data item (string/max length, number, date, boolean).  For a given combination of client and table being extended, there are a fixed number of extension values with well defined characteristics.  I have built and tested a collection and collection item to retrieve and hold these values.  Incidently, the table structure is legacy and cannot be changed at this point; a whole lot of existing application code depends upon this structure.  Some day this might be changed, but not in the near future.

My first thought was to define some kind of list control such as the ListView linked to a CSLADataSource.  Using this approach, I can display the data without difficulty.  The problem comes when I want to allow the values to be updated.  As noted above, I want these extended values to look like all of the other columns for the base business class, sort of a facade pattern.  I just want the user to be able to place values in any of the extended values without requiring any special action (such as a postback to the server).  I am having a brain cramp about how to do this. 

I know that I could dynamically generate the individual controls and explicitly handle the data binding.  My question is, whether there is a simple way to do what I want to do.

Jon Stonecash

JoeFallon1 replied on Wednesday, November 26, 2008

Jon,

I have something similar in my web app. I have a table of metadata for invoice header and line properties. Some of the metadata includes Booleans like ShowUser or ShowApprover. So when I build the screen for the user, if ShowUser=False then that field is omitted.

Therefore, I could see no other way than to "dynamically generate the individual controls and explicitly handle the data binding." It works great. The page is layed out exactly as it is defined by the meatdata for each invoice type. No code changes required, just metadata changes.

Joe

Copyright (c) Marimer LLC