Binding a dataset to GridView

4 posts, 0 answers
  1. Gil
    Gil avatar
    3 posts
    Member since:
    Jan 2013

    Posted 11 Feb 2013 Link to this post

    I'm trying to bind some data from an SQL Server database to a RadGridView.  I'm grabbing the data and storing it in a dataset and I've tested this to see that the data is coming in properly.  I've tried setting the ItemsSource and the DataContext with:
    Grid.ItemsSource = ds.Tables[0].DefaultView;               

    But the data never loads in.  This is my XAML code:

     <telerik:RadGridView Name="Grid" Grid.Row="2" Grid.ColumnSpan="3"  HorizontalAlignment="Center" VerticalAlignment="Bottom"
                                 AlternateRowBackground="AliceBlue" SelectionMode="Multiple"
                                 AutoGenerateColumns="False" MinHeight="300" MinWidth="800"  CanUserResizeColumns="True" CanUserResizeRows="True"
                                 FilteringMode="FilterRow"  IsFilteringAllowed="True"  CanUserSortColumns="True" GridLinesVisibility="Both"
                                 DataLoadMode="Asynchronous"  >
                <telerik:StyleManager.Theme>
                    <telerik:Windows8Theme/>
                </telerik:StyleManager.Theme>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Width="40" Header="Add" DataMemberBinding="{Binding Add}" IsGroupable="False" IsFilterable="True" >                                
                        </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Width="75" Header="Qty"  IsGroupable="False" IsFilterable="True">
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Width="75" Header="Catalog Number" DataMemberBinding="{Binding Catalog_No}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="200" Header="Description" DataMemberBinding="{Binding Description}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="75" Header="Price" DataMemberBinding="{Binding Price}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="75" Header="Min" DataMemberBinding="{Binding Min}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="75" Header="# avl" DataMemberBinding="{Binding Available}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="75" Header="Size" DataMemberBinding="{Binding Size}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="75" Header="Color" DataMemberBinding="{Binding Color}" IsGroupable="False" IsFilterable="True"/>
                    <telerik:GridViewDataColumn Width="75" Header="Style" DataMemberBinding="{Binding Style}" IsGroupable="False" IsFilterable="True"/>
                </telerik:RadGridView.Columns>
                
            </telerik:RadGridView>

    So am I doing something wrong here or do I have to change the way I'm loading in the grid data?  In this case, it would not be impractical to load the data in and fill the grid view by looping through the data, but I'm going to be using the gridview in other places as well where I'll have to load in too much data for that to be a practical solution.
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Feb 2013 Link to this post

    Hi,

     Can you verify if the same DataSet can be bound normally to standard WPF DataGrid? Do you have any binding expression errors in the Visual Studio output window?

    Regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Gil
    Gil avatar
    3 posts
    Member since:
    Jan 2013

    Posted 12 Feb 2013 Link to this post

    I'm able to see the data in a DataGrid.

    I used the following code to set the dataset to the grid
    this.TestDataGrid.DataContext = ds.Tables[0].DefaultView;
    and this code for the xaml:
    <DataGrid Name="TestDataGrid" ItemsSource="{Binding}" Grid.Row="0" >
         
    </DataGrid>
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 13 Feb 2013 Link to this post

    Hello,

     Unfortunately I'm not sure what's going on in your case. Please open support ticket and send us small project demonstrating the problem. We will review your scenario and we will provide more info what is causing the problem. 

    Greetings,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top