Solved

Problem associating linq view with table

Posted on 2011-02-24
9
577 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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