Answered by:
ListView and EntityDataSource - Display multiple tables from model

Question
-
User-543471701 posted
I am new to ASP.NET and Entity Framework. I have been looking around for good examples but I can't find any. I finally decided to ask a question as my last resort. I am hoping that someone here can help me with my problem.
I think the solution is there, but I just can't see it. I need to display 4 tables from an Entity Framework model in a ListView.
The model has a main table called systemUser with some basic information (userId,userFirstName, userLastName, userEmail). All of the tables have a userId. The userId is what connects all 4 tables. When I insert information I need to simultaneously insert into all 4 tables using the same userId.
The tables are as follows:
systemUser:
userId: int
userFirstName: varchar(255)
userLastName: varchar(255)
userEmail: varchar(255)
mobileSystemUsers:
userId: int
mobilePassword: int
companyAccess:
Dev: bit
isEnabled: bit
userId: int
moduleAccess:
accounting: nvarchar(2)
sales: nvarchar(2)
shipping: nvarvhar(2)
When I display data I need to have something like the following:
userId || userFirstName || (all of systemUser) || mobilePassword || VMC || (all of companyAccess) || (moduleAccess data)
A new systemUser should have all of the information filled out in the systemUser page. The other information can exist or be null.
I am using an entitydatasource. This is the first time I use it. I was able to implement this functionality using a GridView and an SQLdatasource but I need to implement this using ListView and entitydatasource.
When I configure the entitydatasource I am only able to select one table.
I also need to perform basic CRUD operations accross all tables at once.
How can I display all of the information from the tables in the manner that I want?
Tuesday, May 20, 2014 1:33 PM
Answers
-
User697462465 posted
Hi David,
There have a tutorial about the how to use entitydatasource to control data, maybe helps:
#Consuming an Entity Data Model using the EntityDataSource control (tutorial)
http://blogs.msdn.com/b/swiss_dpe_team/archive/2009/11/05/consuming-an-entity-data-model-using-the-entitydatasource-control-tutorial.aspx#Getting Started with Entity Framework 4.0 Database First and ASP.NET 4 Web Forms - Part 4
http://www.asp.net/web-forms/tutorials/getting-started-with-ef/the-entity-framework-and-aspnet-getting-started-part-4Hope it helps.
Best Regards,
Terry Guo- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, May 21, 2014 3:46 AM
All replies
-
User-543471701 posted
So I figured out how to display the data from the various tables. All I need to implement now are the CRUD operations.
I am unsure as to where to implement those. Do I implement them using the ListView ItemInserting event or on the EntityDataSource Inserting event?
Tuesday, May 20, 2014 6:04 PM -
User697462465 posted
Hi David,
There have a tutorial about the how to use entitydatasource to control data, maybe helps:
#Consuming an Entity Data Model using the EntityDataSource control (tutorial)
http://blogs.msdn.com/b/swiss_dpe_team/archive/2009/11/05/consuming-an-entity-data-model-using-the-entitydatasource-control-tutorial.aspx#Getting Started with Entity Framework 4.0 Database First and ASP.NET 4 Web Forms - Part 4
http://www.asp.net/web-forms/tutorials/getting-started-with-ef/the-entity-framework-and-aspnet-getting-started-part-4Hope it helps.
Best Regards,
Terry Guo- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, May 21, 2014 3:46 AM -
User-543471701 posted
Thank you for your help. It did help a bit to clear up my confusions. I was finally able to get everything to work.
Wednesday, May 21, 2014 4:54 PM