如何编辑DataGridView并将更改发送回Entity(LINQ)。 [英] How to edit DataGridView and send change back to Entity (LINQ).

查看:107
本文介绍了如何编辑DataGridView并将更改发送回Entity(LINQ)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有WF项目和这段代码:

I have WF project and this code:

 public static void fillDataGridUsers(string inDepartment, DataGridView outList)
        {
            var query = context.Users.Where(g => g.SubDepartment.Department.DepartmentName == inDepartment).Select(i =>
            new UsersForEdit
            {
                Id = i.Id,
                Login = i.Login
            });
            BindingSource bindingSource1 = new BindingSource();
            bindingSource1.DataSource = query;
            outList.DataSource = bindingSource1;
        }
        private class UsersForEdit 
        {
            public int Id { get; set; }
            public string Login { get; set; }
        }

我可以编辑DataGridView,但是不能保存它。

I can edit DataGridView, but cant save this.

  private void SaveGrid_Click(object sender, EventArgs e)
        {
            Core.ControlPanel.Manager.saveGridUsers();
        }


 public static void saveGridUsers(object inUserId, object inValueEditedCell)
        {
 context.SaveChanges();
}

推荐答案

您好ChibiK,

Hi ChibiK,

我认为您可以检查查询变量是否会返回真实列表想。如果数据已在dataGridView中显示。

I think you could check if the query variable will return the true list as you want. and if the data has been shown in dataGridView.

保存时,是否收到错误消息?如果你得到,你可以与我们分享。

When you save, Do you get  error messages? If you get, you could share it with us.

问候,

Youjun Tang

Regards,
Youjun Tang


这篇关于如何编辑DataGridView并将更改发送回Entity(LINQ)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆