473,509 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to databind results of LINQ query from ADO.Net Entity Framework with DataGrid

Hi.
I have SQL Server database that is connected to my WPF desktop-based application via ADO.NET Entity Framework.

Now I need get content of one of the table via LINQ query and show it in DataGrid control. Also, I need to let user to edit or delete data from DataGrid and update my database according this change.

Here is a LINQ query:
Expand|Select|Wrap|Line Numbers
  1. from d in App.glidusContext.tbl_users
  2. select new { d.userID, d.userName, d.userPassword }
  3.  
My DataGrid code:
Expand|Select|Wrap|Line Numbers
  1. <DataGrid x:Name="ContentDataGrid">
  2.    <DataGrid.Columns>
  3.       <DataGridTextColumn Header="User ID" />
  4.       <DataGridTextColumn Header="User Name" />
  5.       <DataGridTextColumn Header="Password" />
  6.    </DataGrid.Columns>
  7. </DataGrid>
  8.  
As I understand I have to use DataBinding mechanism and set DataContext, ItemSource, Mode etc.

I tried a lot of examples from the Internet but most of them don't show how to make it with LINQ query, as result my application fails with InvalidOperationException.

Please, help me with this functionality, this issue really confused me and stops my project.

Thanks.
Oct 9 '10 #1
0 941

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1611
by: TOMERDR | last post by:
Hi, I have Visual studio.NET 2005 on XP proffessional Is it possible to me to use LINQ and ADO.NET Entity Framework? Can LINQ and ADO.NET Entity Framework be used with express editions as...
0
2908
by: Fakher Halim | last post by:
Does someone know any place to get working examples of inherence implemented in Entity Framework using Visual Studio 2008 SP1. I could only implement just one table per hierarchy (...
0
2655
by: Andy B | last post by:
I wanted to try out the ado.net entity framework model and see how it was different from linq to sql entities. I put a page in a web application project, added an ado.net entity model and told it...
9
2246
by: Cirene | last post by:
I'm about to begin a brand new, big, ASP.NET project (using 3.5 .net fw), VS 2008. I'm using MySQL as the backend (customer request.) I have absolutely no experience with LINQ and/or the Entity...
3
1970
by: chris.kennedy | last post by:
I am really struggling to create an entity which maps to 2 "base" entities. I have a customer and invoice entity which are based in tables in a one to many relationship. I have tried: 1....
5
3396
by: John | last post by:
Hi I have installed vs2008/.net3.5 SP1 (details below) but I still can't see ADO.Net Entity Framework under 'New Item' in my WinForm vb.net solution. What am I doing wrong? Thanks Regards
1
2342
by: markla | last post by:
Hi, I have an Entity data model built in Entity Framework, which sources data primarily from an MS SQL 2008 database, and sources some static (data dictionary) values from code-based objects. I...
1
1955
by: Andy B | last post by:
I have to learn how to do one or the other: linq to sql or ado.net entity framework. There will be overhead no matter what way I go since I don't know either one. Which one would be the best one to...
0
2075
by: muratto | last post by:
Hello, I'm trying to build a 3 tier architecture with Ado.NET Entity Framework. I want to select only paged records from Database. But I can't find a solution to make dynamic with Linq to...
2
6410
by: scott1010 | last post by:
Hello I am having problems with a Linq query. I need to return an ID field which is of type GUID (c.Id) along with other fields of type String. I have tried both anonymous types and strongly typed...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.