Bind to column object, not column name.

2 posts, 0 answers
  1. Scott
    Scott avatar
    6 posts
    Member since:
    Jan 2014

    Posted 18 Jul 2014 Link to this post

    What is the correct way use a "DataColumn" object to tell the RadGridView which column to bind to? I can get it to bind using the "ColumnName" property on the column, but I would rather bind on the DataColumn object itself.

    Here is a test program to demonstrate the problem

    <Window x:Class="RadGridViewTest.MainWindow"
                    Title="MainWindow" Height="350" Width="525">
            <radGridViewTest:ContextData x:Key="ContextData"/>
        <Grid DataContext="{StaticResource ContextData}">
            <telerik:RadGridView ItemsSource="{Binding Path=ExampleTable}"
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ExampleColumn}" Header="Via property"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Example}" Header="Via Column Name"/>

    using System.Data;
    using System.Windows;
    namespace RadGridViewTest
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
            public MainWindow()
        public class ContextData
            public ContextData()
                ExampleTable = new StrongNamedDataTable();
                var row = ExampleTable.NewRow();
                row[ExampleTable.ExampleColumn] = "Test Data";
            public StrongNamedDataTable ExampleTable { get; set; }
        public class StrongNamedDataTable : DataTable
            public StrongNamedDataTable()
                ExampleColumn = this.Columns.Add("Example");
            public DataColumn ExampleColumn { get; private set; }

    The column that I set via the property did not work, but the one referencing the column name and the auto generated column both worked. What is the correct way to reference a column using the property?
  2. Yoan
    Yoan avatar
    1215 posts

    Posted 23 Jul 2014 Link to this post

    Hi Scott,

    Generally, if you want to bind GridViewDataColumn to a specific column of your DataTable, you need to use the name of DataTable's column. Please note that you will get the same behaviour with MS DataGrid.

    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.
Back to Top