New to Telerik UI for WPFStart a free 30-day trial

Binding to the DataView of a DataTable

Updated on Sep 15, 2025

This article will demonstrate how to bind a RadGridView to the DataView of a DataTable. An important thing when using a DataTable as a data source for a RadGridView is to make sure that the ItemsSource property of the control is bound to the DefaultView property of the DataTable, which is of type DataView.

Binding to DataTable's DefaultView

Example 1 demonstrates how you can set up a ViewModel containing a DataTable in order to bind it to the RadGridView.

Example 1: Setting up the ViewModel

C#
	public class MyViewModel : ViewModelBase
    {
        private DataTable datatable;
        public DataTable DataTable
        {
            get
            {
                if (this.datatable == null)
                {
                    this.datatable = this.CreateDataTable();
                }

                return this.datatable;
            }
        }

        private DataTable CreateDataTable()
        {
            var dataTable = new DataTable();

            dataTable.Columns.Add(new System.Data.DataColumn("FirstName", typeof(string)));
            dataTable.Columns.Add(new System.Data.DataColumn("LastName", typeof(string)));
            dataTable.Columns.Add(new System.Data.DataColumn("City", typeof(string)));

            for (int i = 1; i <= 50; i++)
            {
                var row = dataTable.NewRow();
                row["FirstName"] = "FirstName " + i;
                row["LastName"] = "LastName" + i;
                row["City"] = "City " + i;
                dataTable.Rows.Add(row);
            }

            return dataTable;
        }
    }

Example 2 demonstrates how the RadGridView is set up in XAML. Please, pay attention to the fact that the ItemsSource is bound to the DefaultView property of the DataTable.

Example 2: Setting up the RadGridView

XAML
	<Grid>
        <Grid.DataContext>
            <!-- The namespace "my" refers to the namespace where the MyViewModel class is defined-->
            <my:MyViewModel />
        </Grid.DataContext>
        <telerik:RadGridView ItemsSource="{Binding DataTable.DefaultView}"
                             AutoGenerateColumns="False"
                             GroupRenderMode="Flat"
                             Margin="5">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}"/>
				<telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}"/>
				<telerik:GridViewDataColumn DataMemberBinding="{Binding City}" />
			</telerik:RadGridView.Columns>
		</telerik:RadGridView>
		
	</Grid>

See Also