0

DataGrid以这种方式显示数据:

var display = (from r in ve.Folders.Include("Hosting_Company1")
               select new RepoClass{ id = r.Folder_Id,name= r.Full_Name, hosName= r.Hosting_Company1.Housing_Name }).ToList();

dg1.ItemsSource = display;

并在XAML

<DataGrid CanUserAddRows="False" AutoGenerateColumns="False" Name="dg1">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding Path=id, Mode=TwoWay}" Header="id"/>
        <DataGridTextColumn Binding="{Binding Path=name, Mode=TwoWay}" Header="Name" />
        <DataGridTextColumn Binding="{Binding Path=hosName, Mode= TwoWay}"  Header="company" />
    </DataGrid.Columns>
</DataGrid>

然后我如何将数据更新到EF?

4

1 回答 1

0

如果 ve 是您的数据上下文,那么您需要调用 ve.SaveChanges()。我通常将一个可观察的集合传递给数据网格,以便更易于管理更改。

于 2013-05-02T21:47:58.860 回答