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.
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.