Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referring to an object by its name
Message
 
À
02/12/2004 07:01:50
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00966331
Message ID:
00966341
Vues:
7
Thanks Cetin,

It does look like a set method but it's not, here's what i'm trying to do: all my controls have 3 custom properties for databinding:
//Lets say we are in a textBox
this.BindTo = "Name"; // the field name to bind to
this.BindTable = "Table1"; // the table to bind to
this.BindProperty = "Text"; // The property of this control to bind
this.SetBinding()

private void SetBinding()
{ 
  this.Databinding.Add( this.BindProperty, this.BindTable, this.BindTo );
}
the problem i have is to pass the object from "this.BindTable" to the DataBinding.Add method.


>>In this code:
>>
>>
>>class TestClass
>>{
>>  private string _myString = "hello";
>>
>>  public TestClass()
>>  {
>>      this.ChangeString( "_myString", "SomeNewValue" );
>>  }
>>  public void ChangeString( string fldname, string newValue )
>>  {
>>      // refer to the field fldname and change it's value to newValue
>>      ??????
>>  }
>>}
>>
>>
>>How can i refer to the myString field and change it's value from it's name ?
>
>Stephane,
>You're somewhat describing a Property set method. Thinking you need for a special purpose cehck System.Reflection class. I believe what you need is FieldInfo:
>
>System.Reflection.FieldInfo[] fi = this.GetType().GetFields();
>
>Cetin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform