web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to return the enum value and description from a base enum and populate a dropdownlist in ASP.Net

(0) ShareShare
ReportReport
Posted on by 790

I'm new to AX development.  I am using AX 2012.  I have a class which is used by a web service to expose it's methods to an ASP.Net web site project.  The web service works fine.

On my web page, I have a dropdownlist control.  I want to create a method in my AX class which will return a list that populates my dropdownlist control.  I have not used enums and I'm not sure how to do this.  So I want to return rows of enums / descriptions that will populate my ASP.Net dropdownlist control.  How can I do this?

*This post is locked for comments

I have the same question (0)
  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi Robert

    In the link below, you can find the x++ code for get values of base enums.

    arsalanax.blogspot.it/.../get-values-of-base-enums-using-code-in.html

    You can create a list of elements to return to your ASP.net application.

  • Robert Herrmann Profile Picture
    790 on at

    Hi Denis,

    I verified your answer a week or 2 ago but I actually have a syntax error when I use the code in the link you provided.  Here is my code:

    private void getTareTypes()

    {

       EnumId     enumId = enumNum(wfsTareType);

       DictEnum  dictEnum = new DictEnum(enumId);

       int                count   = dictEnum.values();

       int                counter;

       for(counter = 0; counter < count; counter ++)

       {

           dictEnum.name(counter);

       }

    This line is underlined in red and says there is a syntax error:

       int                count   = dictEnum.values();

    So what I am I doing wrong?

  • Suggested answer
    Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    AX 2012 offers the Metadata service for this purpose, namely operations GetEnumMetadataByID and GetEnumMetadataByName. You'll get EnumMetadata object and you'll find enum elements in Entries.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans