Continuing: Data binding to a CompositeControl



intrader wrote:
I am very new at using the CompositeControl or CompositeDataBoundControl and at DataBinding in general

My requirement is that I would like to declaratively tell my control to bind to a specific instance of a class; the control then looks at the metadata held in the instance to provide the appropriate control behavior.

The syntax follows the 'standard' <tag:controlname DataSource="here I don't know what to specify" />. What I want in "here I don't know what to specify" is something like instanceName.someFieldOrProperty, where the field (property) has a metadata to describe the behavior of the field.

From within the control I would like to be able to access the field via the DataSource property.

I thought of using an event driven approach and have the control.DataBinding event execute an event handler that would take the DataSource of some container (like a panel) and figure out the metadata in the field of the data source; but, this seems overly complex.

In a nutshell, given an instance fld containing a reference to someClass.someFieldOrProperty, I would like the more direct approach of using DataSource ="fld". Is 'fld' accessible within the code of the control?

Thanks

P.S. I have been following the very good examples in the newsgroup, but I have not figured this out yet.
Recently I have been reading Espositos "Introducing Microsoft® ASP.NET 2.0" section on CompositeControl and TypeDescriptor. Very worthwhile!

I am also studying a very well written article on TypeDescriptors that dwells on their archtecture: "http://blogs.msdn.com/parthopdas/archive/2006/01/03/509103.aspx";. Wonderful article!

I have done some prototype coding that allows me to:

1.Use a Business Object class with properties that are attribute decorated with metadata (similar to the Enterprise Library 3.0):

public class Address:BusinessObjectBase{

[StreetAttribute]string Street{...}
[StatesAttribute]ReadOnlyNameValues States(...)
[ZipCodeAttribute]string ZipCode{...}
.
.
.
}

2.Have a panel-like pagelet control to which I attach an instance of Address myAddress (this may act like an ObjectDataSource class):

<CAFM:pagelet BO="myAddress" .../>

3. Drop a Field objects in the pagelet; the control takes care of naming appropriately for cases where the BO is within another BO or within an instance of a collection:

<CAFM:field Name="Street" />
<CAFM:field Name="States" />
<CAFM:field Name="ZipCode" />

4. They render appropriate controls containing a Title, the control displaying the value - TextBox, DropDownList, TextBox respectivelly

I have gotten to the point where the rendered code looks OK. The postback seems OK, but the naming of the controls becomes a problem if the BO is within another BO or is part of a collection; the design-time is lacking proper display of the metadata driven fields. So I am investigating TypeDescriptor driven design time modification.

I have hoped to get some dialog going on for this thread, but something must be missing in how I phrase or present the thread as no-one has picked up the thread.

Thanks for any help.


.



Relevant Pages

  • Re: Setting sStyle using SetParaFormat
    ... I wouldn't know to recommend an alternative control. ... having anything other than standard Microsoft controls in their deliverables. ... separate structure, and in the cases where the text is editable, I recompute the metadata ...
    (microsoft.public.vc.mfc)
  • Re: What Borland should stop wasting their time on
    ... Jim Cooper wrote in message ... In this case we're only talking about getting metadata under ... > version control. ... Posted with JSNewsreader Preview 1.0.4.2017 ...
    (borland.public.delphi.non-technical)
  • Data binding to a CompositeControl
    ... I am very new at using the CompositeControl or CompositeDataBoundControl and at DataBinding in general ... My requirement is that I would like to declaratively tell my control to bind to a specific instance of a class; the control then looks at the metadata held in the instance to provide the appropriate control behavior. ... I thought of using an event driven approach and have the control.DataBinding event execute an event handler that would take the DataSource of some container and figure out the metadata in the field of the data source; ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Problem with views switching columns
    ... If you have any control over it then scrap it ... and design proper tables is my advice. ... Metadata shouldn't also need to be ...
    (microsoft.public.sqlserver.programming)
  • RE: Finding a way to bind ASP.NET controls(two way) to a typed-dat
    ... the FormView control does support two-way databinding or do I miss something. ... I don’t understand why a custom datasource wouldn’t address my problem. ... The custom datasource can cache the typed dataset in session. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)