Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to edit DataGridView and send change back to Entity (LINQ).

$
0
0

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; }
        }

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();
}



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>