Search code examples
c#winformsado.net-entity-data-model

Binding To ModelContainer()


i"m trying to bind a datagrid object in WinForm to ModelContainer.

i have 2 tables for the examples Students and City. each entity has a property in the ModelContainter.

Moreover, i in debug mode , each entity has a Result View property which stores the whole entity(table) data.

how can i bind it to the datagrid?

this is my code :

// this is the model container from my model.edmx
ModelContainer a = new ModelContainer(); 

datagridview1.DataSource = a;

but i cant find a way to declare the data member.

thanks for the helpers.


Solution

  • Your databinding should go to the tables in the container, e.g.

    datagridview1.DataSource = a.Students;