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

RadGridView: Binding multiple datatables

1 Answer 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dennis van Espelo
Top achievements
Rank 1
Dennis van Espelo asked on 29 Aug 2012, 01:49 PM
Hello,

I would like to know if its possible to bind multiple datatables to a single RadGridView? I need to bind a datatable to populate the grid and beside that I would also like to bind the column header properties.

xaml
<telerik:RadGridView Margin="0"
                            AlternationCount="2"
                            AlternateRowBackground="#d7e8ff"
                            AreRowDetailsFrozen="True"
                            AutoGenerateColumns="False"
                            CanUserFreezeColumns="False"
                            IsReadOnly="True"
                            ItemsSource="{Binding}"
                            SelectionMode="Single"
                            ShowInsertRow="False"
                            RowHeight="30"
                            RowIndicatorVisibility="Collapsed"
                            telerik:StyleManager.Theme="Office_Blue"
                            x:Name="Listing">
 
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="ID" DataMemberBinding="{Binding Path=vis_ID}" IsVisible="False" Footer="Test"/>
                <telerik:GridViewDataColumn Header="{Binding [str_gridview_lastname]}" MinWidth="150" DataMemberBinding="{Binding Path=vis_lastname}"></telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
        </telerik:RadGridView>

cs
// Bind datatable to populate grid
Listing.DataContext = myDataTable;
 
// Bind column header text properties
Listing.DataContext = myColHeaderTable;

The second binding overrides the first binding. Any suggestion to bind both are welcome

Kind regards,
Dennis

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 30 Aug 2012, 11:27 AM
Hi,

You can define the DataTable as a StaticResouce and specify it as a Source directly in the binding. For example:

<TextBlock Text="{Binding Property, Source={StaticResource myColHeaderTable}}"/>

 All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Dennis van Espelo
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or