Hello,
I am running into the error: "The type 'DataRowView' does not contain a public property named 'UnitColumn'" error when trying to edit a cell in the radGridView cell. I am dynamically creating a DataTable to bind to. I have copied the xaml, along with the codebehind for a small sample that illustrates the issue.
Thanks for your help!
Rob
I am running into the error: "The type 'DataRowView' does not contain a public property named 'UnitColumn'" error when trying to edit a cell in the radGridView cell. I am dynamically creating a DataTable to bind to. I have copied the xaml, along with the codebehind for a small sample that illustrates the issue.
Thanks for your help!
Rob
<
Window
x:Class
=
"GridSpike.TestWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local
=
"clr-namespace:GridSpike"
Title
=
"ViewWindow"
Height
=
"400"
Width
=
"500"
>
<
Window.Resources
>
<
local:TestViewModel
x:Key
=
"context"
/>
</
Window.Resources
>
<
Grid
DataContext
=
"{StaticResource context}"
>
<
telerik:RadGridView
ItemsSource
=
"{Binding GridDataView}"
Grid.Row
=
"0"
HorizontalAlignment
=
"Stretch"
Margin
=
"12,12,12,12"
VerticalAlignment
=
"Top"
SelectionUnit
=
"Cell"
x:Name
=
"GridViewTest"
SelectionMode
=
"Extended"
FrozenColumnCount
=
"1"
>
</
telerik:RadGridView
>
</
Grid
>
</
Window
>
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Linq;
using
System.Text;
namespace
GridSpike
{
public
class
TestViewModel : INotifyPropertyChanged
{
public
TestViewModel()
{
LoadGridDataTable();
}
private
DataView gridDataView;
public
DataView GridDataView
{
get
{
if
(gridDataView ==
null
)
gridDataView =
new
DataView(gridDataTable);
return
gridDataView;
}
}
private
DataTable gridDataTable;
public
DataTable GridDataTable
{
get
{
return
gridDataTable; }
private
set
{
gridDataTable = value;
OnPropertyChanged(
"GridDataTable"
);
}
}
private
void
LoadGridDataTable()
{
DataRow row;
DataTable table =
new
DataTable();
table.Columns.Add(
"UnitColumn"
,
typeof
(
string
));
table.Columns.Add(
"01-2011"
,
typeof
(
decimal
));
table.Columns.Add(
"02-2011"
,
typeof
(
decimal
));
//Add test data
for
(
int
i = 0; i < 25; i++)
{
row = table.NewRow();
row[0] =
"Row "
+ i.ToString();
row[1] = i;
row[2] = 1 + 1;
table.Rows.Add(row);
}
gridDataTable = table;
}
#region PropertyChanged Impl
public
event
PropertyChangedEventHandler PropertyChanged;
private
void
OnPropertyChanged(
string
property)
{
if
(PropertyChanged !=
null
)
{
PropertyChanged(
this
,
new
PropertyChangedEventArgs(property));
}
}
#endregion
}
}