Binding a DataSet to a GridviewComboBoxColumn

3 posts, 1 answers
  1. Christophe
    Christophe avatar
    16 posts
    Member since:
    May 2014

    Posted 10 Jun 2014 Link to this post


    I've searched for a while but didn't find anything useful about it.

    I've a dataset, filled with an SQL query which contains a table of many records, and a gridView with a comboboxcolumn. I try to bind my comboboxcolumn with my dataset, but it only displays the first row, in my whole column. For example, if I have 400 records, it displays 400 times the first record.

    Here's my code in my .xaml :

    <telerik:RadGridView HorizontalAlignment="Left"
                                 ItemsSource="{Binding dataSetCameras}"

    etc, and :

    <telerik:GridViewComboBoxColumn Header="Cameras"
                                                    DataMemberBinding="{Binding reference}"
                                        <RowDefinition />
                                        <RowDefinition />
                                    <TextBlock Grid.ColumnSpan="2" Text="{Binding reference}" />
                                    <StackPanel Grid.Row="1" Orientation="Horizontal">
                                        <TextBlock Foreground="#FF356EA6" Text="{Binding sold}" />
                                        <TextBlock Text=", " />
                                        <TextBlock Foreground="#FF356EA6" Grid.Column="1" Text="{Binding broken}" />
                                        <TextBlock Text=", " />
                                        <TextBlock Foreground="#FF356EA6" Grid.Column="2" Text="{Binding stolen}" />

    And in my .cs :

    ((GridViewComboBoxColumn)this.gridViewCameras.Columns["Camera"]).ItemsSource = datas.dataSetCameras.Tables;

    Did I miss something ? And yes, I'm sure that my dataset is filled with the right values.

    Thanks for your help !
  2. Answer
    Dimitrina avatar
    3769 posts

    Posted 12 Jun 2014 Link to this post


    I tested binding GridViewComboBoxColumn to a DataTable.DefaultView and it worked fine, populating all the items available in my table. 
    Would you please try:
    ((GridViewComboBoxColumn)this.gridViewCameras.Columns["Camera"]).ItemsSource = datas.dataSetCameras.Tables.DefaultView;

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. Christophe
    Christophe avatar
    16 posts
    Member since:
    May 2014

    Posted 12 Jun 2014 in reply to Dimitrina Link to this post


    Thanks for your answer, I've finally find out that it works if I write :
    ((GridViewComboBoxColumn)this.gridViewCameras.Columns["Camera"]).ItemsSource = donnees.dataSetCameras.Tables[0].DefaultView;

    I only added [0] in my value but I'd try your solution too. I've written that moments ago but it didn't work, maybe because I forgot to add / change something in my xaml beside. That's why I didn't find the answer sooner.

    Thanks !
Back to Top