I’m using C# in my ASP.NET application, and there are some properties that I don’t want to store in the database. I would like to use a defined struct for these properties, like this:
public struct MedicalChartActions
{
public const int Open = 0;
public const int SignOff = 1;
public const int Review = 2;
}
So I get the integer value when I use MedicalChartActions.Open which equals “0”, but how can I bind it to a DropDownList control so I can display the variable name? How can I get the variable name by the value? For example, how can I return “Open” if the value equals “0”?
Instead of using a structure, I would use an enumerator like SLaks suggested.
Then you can do something like this:
EDIT
Once you’ve changed the struct to an enum, you can get the name from the value like this: