Solved

Problem associating linq view with table

Posted on 2011-02-24
9
579 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
[X]
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
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

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 …
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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