Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing a property by name
Message
De
22/11/2003 14:26:40
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00852561
Message ID:
00852665
Vues:
15
Take a look at Rick Strahl's (great) article on ASP Data Binding (http://www.west-wind.com/presentations/aspnetdatabinding/aspnetdatabinding.asp). In it he demonstrates the use of his wwUtils -class that he wrote to do just what you are looking for.

Setting a property using this class is as simple as this:

wwUtils.SetProperty(object, propertyname, value)

e.g.,

wwUtils.SetProperty(this,"Customer.Address.Street","32 Kaiea")

This method is a reflection wrapper that makes this operation very simple and intuitive. You could of course use "raw" Reflection, if you like typing and want to do it the hard way <g>.




>If I have string specifying the name of a property, how can I use that information to access that property, i.e. store a value to, or retrieve a value from that property?
>
>Thengew.
Pertti Karjalainen
Product Manager
Northern Lights Software
Fairfax, CA USA
www.northernlightssoftware.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform