Skip to main content
Home Forums Silverlight Programming WCF RIA Services Simple Textbox binding?!?!
5 replies. Latest Post by pattormey on November 8, 2009.
(0)
j_mcmullan
Member
2 points
16 Posts
09-22-2009 11:44 AM |
Hello fellow Silverlighters,
I'm hoping that somebody here will be able to shed some light on my problem. From everything I've read this really should be very simple but I can't get it to work!
Now all I want to do is bind a value to a Textbox (txtOtherFactors).
<
The DataContext is set on the parent grid. I have verified that I'm getting data back by binding the whole entity to a datagrid with autogenerating columns but I cannot get it to bind to the Textbox. Any help or suggestions would be greatly appreciated!
Thanks in advance,
Jonny
ColinBlair
Contributor
6579 points
1,291 Posts
09-22-2009 12:08 PM |
The DDS is exposing a collection of entities. The TextBox does not know how to bind to a collection of entities, so you need some other object (such as the DataGrid) to break the collection down into individual entities.
09-22-2009 12:20 PM |
Hi Colin,
Firstly thanks, for the quick reply. If I'm only returning one record can I not bind directly to a specific "column"?
If I can't do that then, would I be best to use something like a dataFormToolkit:DataForm, I don't know much about this control but from what little I've read it might let me bind to the textboxes?
Thanks,
FuryDiamond
3870 points
766 Posts
09-22-2009 12:34 PM |
If it is just a single item, you can simply set the value directly in the code rather than data binding. On the TextBox, you can then add TextChanged to update the data back to the source.
Or you could use a DataConverter along with your data binding to parse the data accordingly.
09-22-2009 12:35 PM |
Hi all,
So it turns out that I needed to use a dataFormToolKit:DataForm. Now I'm able to bind my textboxes to my dds!
Thanks to Colin for pointing me in the right direction!
pattormey
35 points
18 Posts
11-08-2009 9:43 AM |
Hi FuryDiamond,
I have the same issue. BUT I don't want to use the RIA DataForm.
I've got a layout I like and just need to write up the bindings.
I am returning a List<MyData> but it will typically ocontain one item representing a new record. Later people will need to flip thru MyData 'record' using the List<MyData>
So it sounds like I need your suggestion to use a DataConverter to parse the data. That seems like a lot of work to get the one element in the list to be the current item.
Whenever I find myself working too hard I think I'm missing something (g).
So the simple question is.... IF I return a List of Items how can I bind the first one to a text box when NOT using the RIA Data Form.
Seems like I shoud bind to List[0] to display one at a time but I'm new to this so I don't understand.
Can you point me in the right direction?
Thanks