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

How to bind GridViewComboBoxColumn to list of string

3 Answers 297 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deepa
Top achievements
Rank 1
Deepa asked on 12 Jun 2009, 12:08 PM

hi

I have a class in this two property string,list<string> when I bind List<string> to GridViewComboBoxColumn then show empty combobox.how can i achive this problem.please give a example.

<Grid>
        <Grid x:Name="blobsSizeSettings">

            <telerik:RadGridView  Margin="0,0,0,0" Name="BlobSizeSettings" telerik:Theming.Theme="Vista" MultipleSelect="True" 
               AutoGenerateColumns="False" ShowGroupPanel="False" RowIndicatorVisibility="Visible"  Background="White" CanUserFreezeColumns="False"  CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" IsReadOnly="False" IsFilteringAllowed="False"  ColumnsWidthMode="Fill" ScrollMode="RealTime">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn HeaderText="BlockSize" UniqueName="FileSizeString"></telerik:GridViewDataColumn>

                     <telerik:GridViewComboBoxColumn HeaderText="Blocks" ItemsSource="{Binding Size}}"></telerik:GridViewComboBoxColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
           
        </Grid>
    </Grid>

3 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 15 Jun 2009, 08:33 AM
Hi Deepa,

GridViewComboBoxColumn is used when you have a lookup value scenario. A simple example is imagine if we have a Customer object that has a property Country. We want to databind the ComboBox with all countries and bind selected country to the Country property of the Customer.

In your case you should use CellTemplate property of the column to define a DataTemplate with ComboBox. This combo's ItemsSource will be databound to the collection property of your object. I'm sending you an example which illustrates how to achieve this.

Hope this helps.

Regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Deepa
Top achievements
Rank 1
answered on 15 Jun 2009, 09:34 AM
Hi

Thanks for problem solution
if I wants to use GridViewComboBoxColumn instead of cell template I can use it or not if I use It then what approach follow.
0
Stefan Dobrev
Telerik team
answered on 16 Jun 2009, 07:49 AM
Hello Deepa,

If you want to use GridViewComboBoxColumn you should set its ItemsSource to some collection the same you databind the GridView. Check out this forum post for example.

Greetings,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Deepa
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Deepa
Top achievements
Rank 1
Share this question
or