Combine fields in user code and binding dynamically

Posts   
 
    
jonas
User
Posts: 16
Joined: 04-Oct-2005
# Posted on: 04-Oct-2005 10:56:42   

Hi

I want to combine firstname and lastname into a user defined property and I have used the following code:

    // __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
    public virtual System.String Fullname
    {
        get
        {
            return Lastname + ", " + Firstname;
        }
    }
    // __LLBLGENPRO_USER_CODE_REGION_END

My problem is: I want to bind all my controls dynamically and until now we have used the following code to fill a combobox: if(entity != null) { string text = Convert.ToString(entity.Fields[entityDisplayMember].CurrentValue); object data = entity.Fields[entityValueMember].CurrentValue; comboBox.Items.Add(text, data); }

Since the new user defined property "Fullname" is not in the field collection, I would like to know if there is a way to get values from user defined properties without knowing them by name in advance, something like:

string text = Convert.ToString(entity.GetProperty[entityDisplayMember]);

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 04-Oct-2005 13:14:52   

entity.GetType().GetProperty("name"); will return a PropertyInfo, which will allow you to read the value simple_smile

Frans Bouma | Lead developer LLBLGen Pro