Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bound controls
Message
From
07/07/2004 18:25:31
 
 
To
07/07/2004 18:19:25
General information
Forum:
ASP.NET
Category:
Forms
Title:
Miscellaneous
Thread ID:
00921632
Message ID:
00921705
Views:
21
You forgot the quotes around the property name:
txtBoundFormProperty.DataBindings.Add("Text" , this, "FormProperty");
~~Bonnie




>Bonnie,
>
>In the class definition:
>
>public string formProperty;
>public string FormProperty
>   {
>      get { return formProperty; }
>      set { formProperty = value; }
>   }
>
>
>In the forms constructor:
>
>InitializeComponent();
>FormProperty = "hello world";
>txtBoundFormProperty.DataBindings.Add("Text" , this,
>		FormProperty);
>
>
>Getting an exception: Cannot bind to property or column hello world on DataSource.
>Parameter name: dataMember. I've also tried to issue formProperty as the last parameter to DataBindings.Add(). Tried to make formProperty private, same result.
>
>Thanks,
>steve
>
>
>>Yep, you can bind to a property ... but make sure it's a public *property* (with a get/set) and not simply a field (public or otherwise).
>>
>>MyTextBox.DataBindings.Add("Text", this, "MyProperty");
>>
>>
>>~~Bonnie
>>
>>
>>>Learning how to bind controls to objects is giving me fits. It seems that you can only bind a control to an Array (or other collection using the IList interface), or a DataSet (and DataTable, I suppose).
>>>
>>>What if I want to bind textBox.text to a property of a form, or a member of some other class. Can that be done?
>>>
>>>Thanks again,
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