Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple data binding to a property
Message
De
11/09/2003 16:59:48
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00828163
Message ID:
00828333
Vues:
25
Steve,

I remember trying to figure out how to do this about a year ago, and couldn't figure it out ... so I gave up and always bound to a DataTable. So, I still haven't done it, but I'm thinking that maybe all you need to do is have the property implement the IListSource interface ... I'm pretty sure that that is the Interface that provides this functionality (I was gonna try it out first before I answered you, but I'll let *you* try it out <g>).

~~Bonnie



>From reading the docs, this should be possible, but I'm thinking that the DataSource needs to implement an interface that I'm missing.
>
>I'd like to databind a control to a property. The property could be on a form or a business object class or a UI Services class of some kind. The following illustrates the problem.
>
>If I drop two text boxes on a form, I can bind the Text properties:
>
>
>this.txtBoxBound.DataBindings.Add("Text",this.txtBoxSource,"Text");
>
>
>Then, any change in the value of the Text property of one, is reflected in the other.
>
>So far, so good.
>
>Now, I create a form field, txtvalue, and attempt to DataBind the textbox to that field:
>
>
>string txtvalue = "";
>.
>.
>.
>this.txtBoxBound.DataBindings.Add("Text",this,"txtvalue");
>
>
>Or, I create a public property, TxtValue that gets/sets this field, and attempt to bind to it:
>
>
>this.txtBoxBound.DataBindings.Add("Text",this,"TxtValue");
>
>
>In either case I get an exception, "Cannot bind to property or column TxtValue on DataSource"
>
>What'm I doing wrong?
>
>Thanks.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform