O'Reilly logo

Professional ADO.NET 3.5 with LINQ and the Entity Framework by Roger Jennings

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Binding Entities to Data-Aware Controls

Data-binding the Entity Framework's generic ObjectContext.EntitySet collections and their members to data-aware Widows form and ASP.NET server controls follows Microsoft's original Wizard-based drag-and-drop pattern for typed DataSets. In most cases, you use similar databinding methodology with typed DataSets, LINQ to SQL and Entity Framework (EF) data sources. Windows forms require that you add a node for the top-level (master) EntitySet to the Data Sources window; if the relationships/associations have been specified correctly, the master EntitySet will have nested EntityCollection(s) for one:many associations. It's a common practice to drag the master node to the form to create a details view with a BindingNavigator, BindingSource and multiple bound TextBox controls. Nested EntityCollection nodes commonly generate DataGridView controls to enable selection and editing of associated entities. ASP.NET's EntityDataSource control lets developers bind data-aware, sorted, paged GridView or FormView controls to an EntitySet by specifying a few control properties.

A "demoware" stigma afflicts Windows and, to a lesser degree, Web form projects that rely on autogenerated databound controls. The implication is that "real developers don't use wizards and drag-and-drop techniques" to create industrial-quality applications. However, automating the databinding process can markedly increase programmer productivity, especially for small to moderate-size ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required