Solved

Problem associating linq view with table

Posted on 2011-02-24
9
573 Views
Last Modified: 2013-11-11
Hi EE,

I have a listview that is bound to my Products table.  Within this listview I have dropdownlists that are bound to a view.
The reason I am using a view is because I need to display 2 fields from different tables.
The primary key for the view is a key in the Products Table.
I keep receiving an error, saying... Message: DataBinding: 'Service2020.ProductsLU' does not contain a property with the name 'vBrandsTypes'.
I assume it is coming from...
 <asp:Label ID="lblProdcat" runat="server" Text='<%# Eval("vBrandsTypes.ProductType") %>' />

I tried dragging the view onto the table in the dataclass designer, but it did not work.
What can I do to get this to work?

Thanks
0
Comment
Question by:Sheritlw
  • 5
  • 4
9 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34972170
To your statement, "I tried dragging the view onto the table in the dataclass designer, but it did not work.", a view is like a table so when you drag it on to the Linq to SQL design surface drag it to an empty area and NOT on top of another table.
0
 

Author Comment

by:Sheritlw
ID: 34972827
Yes, I know that.  I just thought I read somewhere that I could associate a view with table by doing that.
How can I get my view to link with the table?

Thanks
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 34973462
Hi Sheritlw;

Sorry I misunderstood you. Here is how you can do this.

1. In the design make sure you have your Products table and the View.
2. In the OR/M designer, drag an Association from the toolbox and click on the Primary key field
    in the Products table then click the field in the View that the primary associates with.
3. In the View click on the field which is to be the primary key which was selected in step 2 above.
4. Now open the Properties window and change the property "Primary Key" from False to True.
5. Save and compile, you should be good to go.

Fernando
0
 

Author Comment

by:Sheritlw
ID: 34973816
Hi Fernando,

I tried what you said, except for step # 4 (didn't have primary key option) and I still get the same error.
'Service2020.ProductsLU' does not contain a property with the name 'vBrandsTypes'.
The primary key would be in the View (vBrandsTypes) and the foreign key in the ProductsLU table.
I've attached a picture of how I did it.
Thanks so much for your help.
ScreenShotViewTable.png
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34974339
Hi Sheritlw;

I took the same steps I put in the procedure above and the image below shows the results.

OR/M of Northwind DB with Table & View
Also please not the direction of the association. If it is still not working what version of Visual Studio are you using?

Fernando
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34974353
Pleas note that the Properties panel has a Primary Key property and is set to True.
0
 

Author Comment

by:Sheritlw
ID: 34975131
Hi Fernando.

THANK YOU... It works GREAT!  
I didn't select the id to see it's properties, that is why I didn't see Primary Key.

You are great...
Thanks again.
0
 

Author Closing Comment

by:Sheritlw
ID: 34975136
He is great!
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34975203
Glad to hear that all is working and as always glad I was able to help.  ;=)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now