kala-tamin Datagrid Binding with two tables

Datagrid Binding with two tables

Please help.

I have two relational tables which are Employee and EmployeePosition. I am trying to bind two tables into one datagrid on the xmal file without using LINQ to join those two table into one collection from the c# code behind. HOW CAN I DO IT? The sample code and table below

Empolyee EmployeeID FirstName LastName PositionID

EmployeePosition PositionID Title

My excepted result is:

EmployeeID   FirstName   LastName  Title 

Xaml file

<DataGrid x:Name="DataGrid">   <DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"/>   <DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"/>               <DataGridTextColumn Header="Title" Binding="{Binding Title}"/> </DataGrid> 

The C# Code

var employee = from e in _db.Employees                select e; this.DataGrid.ItemsSource = employee; 

Please help Patrick

XAML markup to use DecimalConverter?


How do I bind a StackPanel to my ViewModel?
The easiest way to do this would be to create a datatable based on a query that selects values from both tables like:.
ASP.NET Using If statement with Container in a list view
SELECT     Employee.EmployeeID,     Employee.FirstName,     EmployeePosition.Title FROM     Employee LEFT OUTER JOIN     EmployeePosition ON     Employee.PositionID = EmployeePosition.PositionID 
If you are using the dataset designer, you can add a new table adapter from the toolbox:.
Can I throw a property changed event for items in a collection bound to my Listbox.ItemSource?
DataSet Toolbox.
Inheriting DropDownList and adding custom values using its DataSourceObject
It may take a moment but the table adapter configuration wizard will appear.

WPF databinding binding error notification
Select your database and follow the steps until you can add a query:.
C#: How to handle “self-references” for tables within DataGridView?
Enter a query....
What's the cleanest way to render the results of a method while data binding?
And then follow the rest of the steps in the wizard.. You'll then have a datatable you can use to bind to your datagrid..

93 out of 100 based on 43 user ratings 693 reviews