Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem associating linq view with table

Posted on 2011-02-24
9
576 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 63

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 63

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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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
 
LVL 63

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 63

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 63

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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