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

RadGridView binding to DataContext?

2 Answers 754 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
ENTERPRISE INTERNATIONAL SAS asked on 08 Sep 2010, 05:12 PM

Hi!

I know setting DataContext = DataTable.DefaultView named MODULES at class scope for a page is enough to bind every component via {Binding ColumnName}. But I note that radGridView is not filled in this way:

public class MyClass

{

public MyClass()
{
   this.InitializeComponent();

}

public void Page_Loaded(object sender, System.Windows.RoutedEventArgs e)

{

DataTable dtbDatos = new DataTable();
GlobalDataBaseManager.ComandoSQL(CommandType.Text, vsSQL, ref dtbDatos);
  dtbDatos.TableName = "MODULES";
   DataContext = dtbDatos.DefaultView;

}

...

<Grid x:Name="pnlConsulta" Height="322">
  <telerik:RadGridView x:Name="grdGridConsulta" ItemsSource="{Binding MODULES}" Margin="19,20.675,23,8" ShowGroupPanel="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoGenerateColumns="False" ColumnWidth="Auto">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="[lblCodigo]" DataMemberBinding="{Binding CA001}" UniqueName="CA001"/>
<telerik:GridViewDataColumn Header="[lblTitulo]" DataMemberBinding="{Binding CA002}" UniqueName="CA002"/>
<telerik:GridViewDataColumn Header="[lblEjecutable]" DataMemberBinding="{Binding CA003}" UniqueName="CA003"/>
<telerik:GridViewDataColumn Header="[lblID]" DataMemberBinding="{Binding CA004}" UniqueName="CA004"/>
<telerik:GridViewCheckBoxColumn Header="[chkInactivo]" DataMemberBinding="{Binding CA005, Converter={StaticResource ValueConverter}}" UniqueName="CA005"/>
<telerik:GridViewDataColumn>
<telerik:GridViewDataColumn.Header>
<StackPanel Orientation="Horizontal">
<Image Height="20" Stretch="UniformToFill" Source="/App_LocalResources/Imagenes/usuarios.png" />
<TextBlock Text="Columna Prueba" TextWrapping="Wrap"/>
</StackPanel>
</telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>

It is not enough to Bind to class DataContext??

thanks

2 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 08 Sep 2010, 05:14 PM
Hi Ramiro,

 Could you please try with an empty binding? E.g. - ItemsSource="{Binding}"

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
answered on 08 Sep 2010, 11:32 PM

Yes!!! It works!!!

thanks very much

Tags
GridView
Asked by
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
Share this question
or