Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referring to an object by its name
Message
From
02/12/2004 10:18:57
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00966331
Message ID:
00966387
Views:
6
Stephane,

What I would do in this situation is to have your BindTable property actually *be* a DataTable, not a string.

~~Bonnie



>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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform