Modify the auto-generated dropdownbox at the top

Last post 07-11-2008 7:41 PM by maira.wenzel. 5 replies.

Sort Posts:

  • Modify the auto-generated dropdownbox at the top

    07-11-2008, 3:31 AM
    • Member
      20 point Member
    • longbcc112
    • Member since 07-10-2008, 8:35 AM
    • Posts 35

    After I drag the db table into dbml and then run the website,
    I discover that dropdownboxes are generated automatically at the top of the page.

    It seems the dropdownboxes depend on the child table.
    The data in the dropdownbox is the first column other than the primary key.

    In my case (I have 4 tables: campaign, user, path, marketer):
    Campaign depends on user and marketer.
    User depends on marketer.
    Paths depends on Campaign.
    Marketer doesn't depend on any table.

    I want to change the data in the dropdownlist so that the dropdownlist in the path page has data of the column campaign_name_EN instead of Campaign_identifier.
    How can I do it?
    Thanks a lot!!

  • Re: Modify the auto-generated dropdownbox at the top

    07-11-2008, 4:18 AM
    Answer
    • Contributor
      2,024 point Contributor
    • marcind
    • Member since 09-06-2007, 5:11 AM
    • Redmond, WA
    • Posts 410
    • AspNetTeam

    Hi,

    you can use DisplayColumnAttribute to declare which column should be used for displaying the entities.

    Marcin Dobosz
    SDE, ASP.NET Team, Microsoft
    Read my blog
  • Re: Modify the auto-generated dropdownbox at the top

    07-11-2008, 5:38 AM
    • Member
      20 point Member
    • longbcc112
    • Member since 07-10-2008, 8:35 AM
    • Posts 35

    I create a class2.cs and put it into App_Cod eto try to use this attribute:

     However, I don get the DisplayColumn hint when I enter [D in the file.

    [D <------"[DisplayColumn(" does not show up for me to use
    public partial class Campaign{
    }

    What's the possible reason about this?

  • Re: Modify the auto-generated dropdownbox at the top

    07-11-2008, 5:55 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 5:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    Hi longbcc112 are you running the latest bits?

    you can get them here:

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Modify the auto-generated dropdownbox at the top

    07-11-2008, 11:25 AM
    Answer
    • Contributor
      2,024 point Contributor
    • marcind
    • Member since 09-06-2007, 5:11 AM
    • Redmond, WA
    • Posts 410
    • AspNetTeam

     DisplayColumnAttribute is in the System.ComponentModel.DataAnnotations namespace. You need to have it included/using for intellisense to provide it.

    Marcin Dobosz
    SDE, ASP.NET Team, Microsoft
    Read my blog
  • Re: Modify the auto-generated dropdownbox at the top

    07-11-2008, 7:41 PM
    Answer
    • Member
      511 point Member
    • maira.wenzel
    • Member since 06-11-2003, 12:12 PM
    • Posts 111
    • AspNetTeam

    This is how your class shoud look like:

    using System.ComponentModel.DataAnnotations;
    
    [DisplayColumn("Campaign_Name_EN")]
    public partial class Campaign
    {
    }

    I hope this helps.

    Maíra  

    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (6 items)