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

[Solved] Bind ComboBox

2 Answers 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kennet
Top achievements
Rank 2
Kennet asked on 21 Sep 2009, 04:48 PM
I spent hours reading forum and trying to code, but no...

I have a combobox in a grid, items to combo comes from separate domaindatasource than the grid. Data is showing in combo in the grid. But The proper item in combo is not selected (nothing is selected when grid is loaded). But if I double click on the combobox in a row, then I see the proper item in combo. So the values are there, just not "auto selected" when grid is loded.

I use RIA service.

What to I need to do, so the combobox show correct Item. And I also need to save the value if I change item in combo.

XAML (dds for the combobox items)
 
        <riaControls:DomainDataSource x:Name="DomainDataSourceCmb" AutoLoad="True" LoadSize="100" QueryName="GetSongcategoriesSet" LoadedData="DomainDataSourceCmb_LoadedData">  
            <riaControls:DomainDataSource.DomainContext> 
                <ds:MediaContext/> 
            </riaControls:DomainDataSource.DomainContext> 
        </riaControls:DomainDataSource> 

 

 

 


C#
 
private void DomainDataSourceCmb_LoadedData(object sender, LoadedDataEventArgs e)  
        {  
 
            ComboBoxEditorSettings comboBoxEditorSettings = new ComboBoxEditorSettings();  
 
            comboBoxEditorSettings.DisplayMemberPath = "longname";  
            comboBoxEditorSettings.SelectedValuePath = "guid";  
 
            comboBoxEditorSettings.ItemsSource = DomainDataSourceCmb.DataView; //.Data  
            ((GridViewDataColumn)this.RadGridView1.Columns[5]).EditorSettings = comboBoxEditorSettings;  
 
        } 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Kennet
Top achievements
Rank 2
answered on 23 Sep 2009, 04:44 PM
Anyone? Telrik support...?

Please help me out here.
0
Pavel Pavlov
Telerik team
answered on 24 Sep 2009, 11:47 AM
Hello Kennet,

I think for your scenario using the GridViewComboboxColumn is the best choice. It will automatically create the editor settings for you . For more details please have a look here.
The GridViewComboBoxcolumn will take care to show the display member even when the cell is not in edit mode.
The editor settings control only the editing state of the cell.

If you need any furhter assistance just let me know.

Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Kennet
Top achievements
Rank 2
Answers by
Kennet
Top achievements
Rank 2
Pavel Pavlov
Telerik team
Share this question
or