.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

DataGridComboBoxColumn data binding for an Entity Framework foreign key relationship

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :WPF

I am using Entity Framework and want to show a foreign key relationship in a datagrid using a combobox; I cannot find any good instructions on how to do the data binding.  Here is a simplified example:

City: (CityID, CityName, StateID)  Collection: Cities
State: (StateID, StateName)  Collection: States

The Window constructor:

        public MainWindow()

            /* get a database context for the entity framework */
            MyEntities dbContext = new MyEntities();

            /* bind the data controls */
            this.DataContext = dbContext;

This XAML for the DataGrid will display the State Name as a Readonly Text Column:

                            <DataGrid AutoGenerateColumns="False"

View Complete Post

More Related Resource Links

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Data accessors or Entity framework


The entlib 5 sugest me to use with data accessors for mapping data from database to my data objects (ORM).

But in .NET 3.5 and especially in .NET 4, I can use in entity framework as ORM methodology for data objects.

What data accessors uses advantages over the entity framework?

What differences that should be affect on my using decisions?

Data Points: Deny Table Access to the Entity Framework Without Causing a Mutiny


Julie Lerman shows database administrators how to limit access to databases from the Entity Framework by allowing it to work only with views and stored procedures instead of tables-without impacting application code or alienating developers.

Julie Lerman

MSDN Magazine August 2010

VS 2010: Entity Framework 4.0 and WCF Data Services 4.0 in Visual Studio 2010


Elisa Flasko takes you through a sample weblog application to demonstrate how new improvements in Entity Framework and WCF Data Services work together to simplify the way data is modeled, consumed and produced in Visual Studio 2010.

Elisa Flasko

MSDN Magazine April 2010

SOA Data Access: Flexible Data Access With LINQ To SQL And The Entity Framework


Building a data access layer using LINQ to SQL and the ADO.NET Entity Framework allows you to decouple your application from the persistence technology you're using.

Anthony Sneed

MSDN Magazine December 2008

ADO.NET: Achieve Flexible Data Modeling with the Entity Framework


Here the author answers questions regarding the Entity Framework and provides an understanding of how and why it was developed.

Elisa Flasko

MSDN Magazine July 2008

Data Points: The Entity Framework in Layered Architectures


Here we build a solution that fits the Entity Framework into an n-tier architecture that uses WCF and WPF and the MVP pattern.

John Papa

MSDN Magazine July 2008

Data Points: Entity Framework Q&A


The Entity Framework is a hot topic, but how do you know when to use EntityClient, Object Services, Entity SQL, or LINQ? Find out here.

John Papa

MSDN Magazine May 2008

Data Points: ADO.NET Entity Framework Overview


The new Entity Framework in ADO.NET will let you manipulate data using an object model. John Papa explains.

John Papa

MSDN Magazine July 2007

Dynamic Data Entity Framework Filters



I'm working on EF DynamicData project (for .NET 3.5) and I didn't manage to find any code or examples for filters like in Dynamic Data Filtering (http://dynamicdatafiltering.codeplex.com/) or Dynamic Data Futures that support Entity Framework (the versions are for Linq2SQL only). 

The primary functionality that i want implement is having dynamic textboxes for searching datagrid based on the filterAttribute. Can You help me with an idea or some guideliness how to implement it or make modifications on something existing?

Entity Framework 4.0 Dynamic Data - stored procedure


I'm using Dynamic Data and have created a custom List.aspx page.  I simply want to populate the grid with a stored procedure.  I've seen some posts about doing this with a LinqDataSource but not an EntityDataSource.  Does someone have an example or a different way of doing this?  Thanks.

ASP.NET and Entity Data Framework - Best Practices?

Hi I'm looking for some advice regarding using EDF and ASP.NET. My main concern is the use of contexts within my code. What is the best way to handle contexts?  Currently I'm getting the dreaded error: "An entity object cannot be referenced by multiple instances of IEntityChangeTracker."  What's the best way to ensure I'm using the same context? What are the implications for leaving a context 'open' in the Session? Is this a big 'no no' ? How can I achieve a consistent approach (without having to pass context parameters all over the place) and yet keep my application scalable? Thanks, Simon.

Dynamic Data Entity Framework: Initial Sort Order for Views

Hello Steve,I'm trying to set an initial sort order for my View (not table) in Dynamic Data using Entity Framework 2. I have updated my Model and Imported the View. Now I'm trying to use the DisplayColumn attibutebut it's not working.[DisplayColumn("Product", "ParsingOrder", true)]Fabio

Entity Framework POCO and WCF Data Service - Lazy-loading (expand?) related entities?

I've followed ScottGu article on creating an Entity Framework POCO classes for NerdDinners (right now there are only 2 classes, Dinner and RSVP. I then created a WCF Data Service class, which points to my EF class (NerdDinner), everything is working fine, except I can't lazy-load or expand related entities. For example, I want to get all load all the Dinners and their related RSVPs, something like this throw an error:var result = (from d in db.Dinners.Expand("RSVPs")                      select d);The error is a null reference error:at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, Object customObject, ResourceType resourceType, Uri absoluteUri, String relativeUri, SyndicationItem item, DictionaryContent content, EpmSourcePathSegment currentSourceRoot) at System.Data.Services.Serializers.SyndicationSerializer.WriteEntryElement(IExpandedResult expanded, Object element, ResourceType expectedType, Uri absoluteUri, String relativeUri, SyndicationItem target) ... ... ...Any idea why or what I need to do to load related contents?Thank you very much.

Cannot drag an Entity Framework Data Source (created in a separate solution) onto WPF Design Surface


I receive the error Cannot add the control to the design surface or bind to the contol because the type Pec.CustomerEntity.Carrier, Pec.CustomerEntity,Version=, Culture=neutral, PublicKeyToken=null cannot be resolved.  Please try to build the project or add necessary assembly references  (I have rebuilt and it still doesn't work)   -  when I try to drag the data source onto the window. 

If I create an entity framework project within the wpf application solution and create a data source and reference to it, it works fine when I drag the data source onto the window.  I only get the error when I create a reference to an EF project .dll created outside of the wpf project.  I am using Visual Basic 2010.    I have also tried adding the project to the wpf solution and it still gives me the error. 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend