locked
problem with displayed column names in foreign key fields RRS feed

  • Question

  • User-116525033 posted

     Hi,

    to explain my problem I try to give a sample. I have two db tables which are related with two foreign keys:

     

    table1               table2
    ------ ------
    field_1a ------> field_2a
    field_1b ------> field_2b

      

    Now I changed the displayed names of the fields :

     
    [DisplayName("name of field_1a")]
    public object field_1a { get; set; }

    [DisplayName("name of field_1b")]
    public object field_1b { get; set; }

     

    When I view the List.aspx for table1 the column names are "table2" and "table21" instead of  "name of field_1a" and "name of field_1b", so the column name is always the name of the related table2, not the defined [DisplayName("xyz")]

     

    Can I change this behavior?

     

    Wednesday, August 27, 2008 5:59 AM

Answers

  • User-116525033 posted

     Ok, I got it working now.

    My mistake was, to set the DisplayName attribute to the colums not for the association. Now its working like exspected :-) 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 27, 2008 1:01 PM

All replies

  • User-1763611275 posted

    Hi

    you can try to make inner join between two tables as they have realation

    Good Luck

    Wednesday, August 27, 2008 6:28 AM
  • User-116525033 posted

     Hi,

     

    I think we talk about different things.

    I talk about the presentation of foreign key columns on a List.aspx website (the header of the column in the HTML table). This column name is the name of the related table which overwhelms the setting for the column name in the currently dislayed table. So if two DB tables have three relations I get three columns with the header "table2", "table2", "table2"

    Wednesday, August 27, 2008 10:00 AM
  • User-116525033 posted

     Ok, I got it working now.

    My mistake was, to set the DisplayName attribute to the colums not for the association. Now its working like exspected :-) 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 27, 2008 1:01 PM
  • User-1614457691 posted

    ...to set the DisplayName attribute ... for the association...

    How did you do that?

    Where?

    Please advise.

    I am getting this error...

    Attribute 'Association' is not valid on this declaration type. It is only valid on 'property, indexer, field' declarations

    ...but I do not know exactly how to fix it.

    Thank you.

    -- Mark Kamoski

     

    Wednesday, August 27, 2008 1:21 PM
  • User-1614457691 posted

    FYI, I found my answer.

    I need to declare the Association in the Metadata for the target partial class, like this...

    [DisplayName("Submitter Information")]

    public object Submitter_Informations { get; set; }

    ...but I was doing it in the wrong object.

    In phraseology that may only make sense to me, I would say...

    I was doing it in the object-being-pointed-to (which is not correct).

    I should have been doing it in the object-doing-the-pointing (which is correct).

    (I appreciate the seminal post here because I would not have found my answer without it.) 

    HTH.

    Thank you.

    -- Mark Kamoski

    Wednesday, August 27, 2008 1:38 PM