This is a migrated thread and some comments may be shown as answers.

DataFormComboBoxField in a RadDataForm

1 Answer 242 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 09 Oct 2013, 07:57 PM
I have followed the example below and scoured the internet for 2 days trying to get my combobox to work correctly, and I still cannot get it to select the correct item when the form opens. http://www.telerik.com/help/silverlight/raddatafor-edit-lookup-values-with-radcombobox.html

I have two classes (generated by the Openaccess ORM), one of which contains information about musicians (name, id, genre etc) and a second class that contains information about the type of musician (band, festival, performing arts etc). I have successfully added a couple of simple textbox controls to the form that display the artist name and some other basic information, and now I am trying to pick the artist type from a combo box.

I can successfully populate the combobox from the ORM model "ArtistType" class,  but no matter what I do it always opens either with the first item selected (regardless of the actual underlying value) or nothing selected at all. If I break the code in the combobox_Loaded event, I can see the values, but they are never reflected in the combobox.

How can I databind a simple numeric value in a primary table to a list of items in a second table to be displayed as a picklist in a combox?

1 Answer, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 09 Oct 2013, 09:19 PM
Never mind. I fixed it.

Would have been nice to have that example mention that I needed to databind the ArtistTypes table in the grid, and not just the ID from the Artist table, because my implementation sure doesn't look much like the example above.
<telerik:DataFormDataField Grid.Column="0" Grid.Row="0" Label="Artist Name" DataMemberBinding="{Binding ArtistName, Mode=TwoWay}" />
<telerik:DataFormComboBoxField Grid.Column="0" Grid.Row="1" Label="Artist Type"
    SelectedValuePath="ArtistTypeID"
    DataMemberBinding="{Binding ArtistType.ArtistTypeID, Mode=TwoWay}"
    DisplayMemberPath="TypeDesc"
    ItemsSource="{Binding ArtistTypes, Source={StaticResource MyModel}}"/>
Tags
DataForm
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Share this question
or