Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 16, 2013 07:49 AM by sjnaughton
Jan 10, 2013 12:20 AM|LINK
I understand that dynamic data will by default display the first string column from the related foreign key table, but I was wondering is it possible to display the other columns related to the foreign key as well? I've seen the example where the ToString
function is overloaded, but I'd like to keep the columns seperate and I'd like to be able to display columns of any datatype such as boolean or integer.
Jan 10, 2013 04:39 PM|LINK
Yes you can do this.
Jan 10, 2013 05:17 PM|LINK
Can you elaborate or point me to example on how to do this?
Jan 10, 2013 08:28 PM|LINK
How about posting some of your code so we can see what you are doing and offer suggestions from there.
Linking to a record using a foreign key is really no different that writing the query by using a join.
Jan 10, 2013 08:56 PM|LINK
Here is an example:
I have a table called Products with two fields ProductName and ProductCategoryID.
I have a second table called ProductCategories with the fields CategoryID, CategoryName, CategoryDescription, CategoryRank
Products.ProductCategoryID and ProductCategories.CategoryID are foreign keys.
Out of the box Dynamic Data automatically displays the CategoryName when I view the List page of the Products table.
What I want is to be able to display the CategoryDescription and CategoryRank as well (in their own columns) in the List page of the Products table.
Jan 12, 2013 02:26 AM|LINK
Just override the ToString method and then combine the two properties something like this below:
public override string ToString()
Jan 14, 2013 06:04 PM|LINK
That works for a single column, but I need the properties to be in their own columns.
Jan 15, 2013 12:10 AM|LINK
the properties to be in their own columns.
What does this mean?
Jan 15, 2013 02:13 PM|LINK
This means I want the fields to be in separate columns ie. a column for CategoryName and a column for CategoryDescription. Overloading the ToString function only creates a single column that combines the two.
Jan 15, 2013 02:14 PM|LINK
Hi jvdub22, sorry this not possible you can only use the ToString function to combine then into a display string, the main issue here is EF.
but I'd like to keep the columns seperate and I'd like to be able to display columns of any datatype such as boolean or integer
I have a simple work around if you are not averse to using Computed Columns in SQL Server?