Displaying data from linked fields

Hi,

I've got this link table, lets call it "Link". It has 3 fields: ID, RepresentativeId and CityId. There are two other tables called Representatives and Cities, each with another ID.

Link.RepresentativeId <-> Representatives.ID
Link.CityId <-> Cities.ID

Now... I want to display a drop down which returns the ID of the Link as the value, but the Display Member should be a text contatenation of the representative's name and the city name.

How can I manage this

Thank you,
Bram



Answer this question

Displaying data from linked fields

  • higgins427

    I've tried this and it seems to work partially. The content being retrieved from the linked column seems to suck up everything else, like a multiplication with 0.

    If the expression is "ID", it works.
    If it's "ID + ': '" it works.
    If it's "ID + ': ' + Parent(Representative_Link).LastName" the fun is over. LastName is filled it, so no null values there.

    Then I added a IsNull() function. It seems the linked field is actually a null value. I found something about a Child() function instead of a Parent() function, but that doesn't seem to work...

    What's still wrong

  • G&amp;#252;nter

    Interesting fact: when I click "Configure..." on the context menu of the data table in the XSD editor, I get the error message:

    ---------------------------
    Error
    ---------------------------
    Configure TableAdapter AjO failed.

    Cannot find the parent relation 'OpleidingenAcademiejarenOpleidingen'.
    ---------------------------
    OK  
    ---------------------------


    However... It is there, this relationship.

    To explain it somewhat kiddy-like: at the link table, there's a chain icon. At the detail table, there's a key icon. Isn't it a child then


  • christian rysgaard

    I got it working on a totally different table. I think I need to search in the direction of consistency in the relationships. But... It does work! Smile Thank you!
  • srgibson

    I made VS.NET generate all Data Adapters, so I could only hope they're correct. Interrogating each individual table works like a charm, so I guess the DA's are OK. (I've tested this by linking a Data Adapter to a Data Grid View.)

    I've tried implementing this way of working anyway into my bigger solution. This is the expression I used:


    Parent(AcademiejarenAcademiejarenOpleidingen).AanvangsjaarAfsluitjaar + ': ' + Parent(OpleidingenAcademiejarenOpleidingen).Naam + ' ' + Parent(OpleidingenAcademiejarenOpleidingen).Jaar
     


    I have to admit that "AanvangsjaarAfsluitjaar" is an expression by itself too, but removing that doesn't do the trick. The DropDownList stays empty.

    Tried binding to a Data Grid View too, but again: empty.


  • Kushal

    Are you sure you load the dataset correctly
    The specific example requires the creation of 3 Data Adapters, one for each table.

    You should use Child function if the Representative is Child table of Representative-Link Relation.


  • Jorge Lalinde

    You have to add an expression column on Link table with the following expression:
    Parent(Representative_Link).FirstName + ' ' + Parent(Representative_Link).LastName + ' (' + Parent(City_Link).Name + ')'

    I sent you a personal e-mail at "msdn dot forums at a dot brammeke dot net", since I can not add an attachment here.


  • Displaying data from linked fields