0

I'm using ASP.NET dynamic data to create a ticket edit form. The Ticket is associated to a problem code, but not using the problem code's primary key. (The database is 3rd party, so I don't have control over that...)

So the problemCode looks basically like:

ProblemCode
(
    ID int,
    Code varchar(8),
    Description varchar(250)
)

The association is between Ticket.ProblemCode and ProblemCode.Code

Now the problem is that ForeignKey_Edit (really, PopulateListControl) fills the dropdown with the Primary Key which is ID... but the ticket is actually using Code to tie the two together. Am I missing something? Is there a simple way to get it to use Code as the value instead?

If not I can probably eliminate ID from the view as I don't think it HAS to be used anywhere... I just like having an ID around.

animuson
  • 53,861
  • 28
  • 137
  • 147
CodeRedick
  • 7,346
  • 7
  • 46
  • 72
  • Are you using LINQ to SQL or Entity Framework? Did the foreign key relationship from the DB get pulled into your "DataContext" correclty? – Aaron Hoffman Jul 08 '09 at 14:01
  • Linq to SQL, and I manually set up the foreign key relationship because it's based on views. – CodeRedick Jul 08 '09 at 16:26

1 Answers1

1

Try this in your metadata:

[DisplayColumn("Code")] 
public partial class ProblemCode{ }
Ash Machine
  • 9,601
  • 11
  • 45
  • 52