How to make two way-databinding using EF in winforms?

前端 未结 1 1999
难免孤独
难免孤独 2021-01-19 01:56

I am very new at coding. Now I am going to tell you about my current situation and where I wanna go. Hope you will help.

I am using EF5.0 database first approach and

1条回答
  •  囚心锁ツ
    2021-01-19 02:28

    If you bind to query result you are using only one-way data binding. You need to have IBindingList to get two way data binding. Try this:

     ctx.Kolons.Load();
     dataGridView1.DataSource = ctx.Kolons.Local.ToBindingList();
    

    If it doesn't work try to use BindingSource:

     ctx.Kolons.Load();
     gridBindingSource.DataSource = ctx.Kolons.Local.ToBindingList();
     dataGridView1.DataSource = gridSource; 
    

    0 讨论(0)
提交回复
热议问题