Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databinding issue

Status
Not open for further replies.

hawkdernacht

Programmer
Mar 10, 2005
15
US
Hello all, I have an issue with databinding on the .Net Compact Framework. I can get an array of objects to bind to a datagrid via a binding source control, no problems. But when I try to do the same exact thing to a text box I get the error "Cannot bind to the property or column Comment on the DataSource.
Parameter name: dataMember"

Any thoughts? Am I missing something here?

Regaurds

The Nighthawk,
"Don't try to reinvent the wheel, unless you can make it better.
 
To bind to a textbox you need to use the DataBindings.Add method. Can you show the code you're using?
 
I have tried a number of methods, including VS.Net designer tools, all have the same issue. But here is one example.

Me.txtComments.DataBindings.Add("Text", Me.m_Order, "Comment", True, DataSourceUpdateMode.Never, "")

Where Me.m_Order is a member varialbe of a custom type, and the Comment is a string property of that type. The type is not a null ref or any such thing, I can pop a msgbox in front of the binding code and have it display the expected text.

Regaurds

The Nighthawk,
"Don't try to reinvent the wheel, unless you can make it better.
 
OK...what type of source are you using? If you're just trying to put a variable into the text box you should use textbox.text = someVariable.

The databindings is most often used to connect a DataSet to the textbox.
 
I am using a binding source as an intermediary, howevery I have tried binding directly to the object as shown in the code I posted. Either way, same issue. I really would like to use databinding, but I am afraid I am going to have to manually bind all of this data, and make sure it stays accurate when my source changes.

Regaurds

The Nighthawk,
"Don't try to reinvent the wheel, unless you can make it better.
 
OK...what type of source are you using? All that you've said is that the source is of a custom type. Without more details, it's very difficult to help you find a problem. Typically, you only bind a list or recordset (something with multiple entries) to a control. From the looks of the error message, it's saying that it can't bind to "Comment". Without seeing the code I can't be sure, but I'd float a guess that the "custom type" you created doesn't have it's data in an IList format.
 
Well with the advent of .Net 2.0, the BindingSource control can bind to an object, moreover it can bind not only to a specific object, but to a type. I have done this many, many times in the full framework. So I am not sure what more you need about my data source, it is just a class named WorkOrder, one of the r/w public properties is Comment which returns a string held inside of a private string memeber variable.

Regaurds

The Nighthawk,
"Don't try to reinvent the wheel, unless you can make it better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top