I use Telerik component (RadTreeView) in winforms with Entity Framework 6 . I config it as is:
radTreeView1.DataSource = db.Projects.ToList();
radTreeView1.DisplayMember = "Name1\\Name2";
radTreeView1.ValueMember = "Id1\\Id2";
radTreeView1.ChildMember = "Projects\\ProjectItems";
When I add new record to a table Programmeically, radTreeView1
won't update. even i use this:
db.SaveChanges();
radTreeView1.Update();
radTreeView1.Refresh();
I have change my code to this :
radTreeView1.DataSource = null;
db.SaveChanges();
radTreeView1.DataSource = db.Projects.ToList();
radTreeView1
is updated when i edit a record, or add new record to ProjectItems
table.
but this error is happen when i add new record to Projects
table.
Error:
An unhandled exception of type 'System.Reflection.TargetInvocationException'
occurred in System.dllException:Thrown: "Property accessor 'ProjectItems' on object 'ProjectControl.DAL.Project' threw the following exception:'Object does not match target type.'" (System.Reflection.TargetInvocationException) A System.Reflection.TargetInvocationException was thrown: "Property accessor 'ProjectItems' on object 'ProjectControl.DAL.Project' threw the following exception:'Object does not match target type.'"
can someone help me?