p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > Other .NET > ADO.NET
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .

Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 21st, 2009, 10:12 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2009
Location: Boise, Idaho
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default databind problem with templateField in details view - related to entity framework

Hello all,

I have a question that must have come up before. I have a project that is based on ADO.NET and Entity Framework and I am trying to build a master/details view. Most of it works, but there is a problem I haven't been able to solve:

I need to prepopulate four fields in the details view with information - a task creation date, userID of the creating user, a boolean task flag, and the ID of the related class. Of these, two fields are foreign keys from related (and associated) tables.
The problem arises when I turn D_USER.ID and D_CLASS_SESSION.ID into template fields. In the model.edmx file, these two fields are (of course) navigation properties called D_USER and D_CLASS_SESSION respectively.
When converting these two database fields from databound controls to templateFields, the following properties are added to the respective ItemTemplates:
Code:
Text='<%# Bind("[D_USER.ID]") %>'
Code:
Text='<%# Bind("[D_CLASS_SESSION.ID]") %>'
When called, the following error is generated as the value of the property is truncated at the period:
DataBinding: '[D_CLASS_SESSION' is not a valid indexed expression.

I've found postings that recommend removing the square brackets ('[' & ']') from the statement, but that seems to break the item's connection to the database, as it causes an error on inserting or editing.

Given the nature of the entity framework, it seems to me that all navigation properties would have similar problem when used in this manner.
how do I correct this?

Thanks,
Les Berg
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 25th, 2009, 01:45 PM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2009
Location: Boise, Idaho
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So the problem seems to be that a foreign key field will not display as a template field. I cannot for the life of me understand why this could possibly be the case, given the nature of relational database design and programming. In using Entity Framework, these fields become 'navigation properties'. I understand that Entity Framework is a new technology, but there has to be a way to use these fields in a template field, such as those found in a Form View.

Does anyone know how to do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old August 26th, 2009, 01:19 AM
Friend of Wrox
Points: 741, Level: 10
Points: 741, Level: 10 Points: 741, Level: 10 Points: 741, Level: 10
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 211
Thanks: 1
Thanked 7 Times in 7 Posts
Default

LesBerg:

I would check the CSDL (Conceptual Schema) which holds the E-R diagram and their relationships.

Found this article, which is a tutorial on the Entity Framework. According to the article, navigation properties are the table names.

http://geekswithblogs.net/kobush/arc...amework_1.aspx

The article is short but informative.

Hope this helps.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old August 26th, 2009, 01:49 PM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2009
Location: Boise, Idaho
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! I'll check the article out. I also discovered that I needed to add the 'include' property to the entityDataSource with a comma-delimited list of the navigation properties. So far this lets me display data correctly. I hope to have enough code completed today to see if update and insert modes work correctly.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Switching To entity framework luckystar BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 0 July 31st, 2009 10:52 PM
Entity Framework And MVC geomar BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 3 June 19th, 2009 05:06 AM
Entity Framework rkanagy BOOK: .NET Domain-Driven Design with C#: Problem - Design - Solution ISBN: 978-0-470-14756-6 0 May 4th, 2009 08:29 AM
populate details view or list view non empty rows iinfoque ASP.NET 2.0 Basics 0 March 11th, 2007 07:11 AM
Problem with Details View and Multiple DataSources safin ASP.NET 2.0 Professional 1 April 23rd, 2006 02:41 PM



All times are GMT -4. The time now is 03:06 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc