ObjectDataSource and Displaying Foreign Keys

N

Nightcrawler

Dear Group,

I went ahead and used the wizards to create a dataaccesslayer of my
database. I checked all my tables and in matter of a few seconds all my
tables and relations appeard in VS2005. I then configured the
dataadapters for each table to use automatically created stored
procedures by VS2005. Each table now has a select, insert, update,
delete query. So far so good.

The problem happens when I try to bind a table (Products) to a GridView
through the ObjectDataSource. Getting the data to display is easy. The
problem is that I don't want to display CategoryID in my gridView, I
would rather fetch the actual CatgeoryName which lives in another table
(Category) and CategoryID is a foreign key in my primary table
(Products).

Is there an easy way to do this in a web application? Or am I forced to
add a new query to my ProductTableAdapter and write a new stored
procedure that does a join query of the two tables? I tried that and
when I go to "define columns" in the GridView, CategoryName still
doesn't show up even if it's in the query. VS2005 also warns me when I
add queries that join multiple tables. Given this I can't help but
think that there must be an easier way.

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top