Work is often encountered in the use of enumeration, of course, the use of the foreground page enumeration is mostly direct calls, and design to the background of the management often use the enumeration as a 1 collection to be used
list<fineui.listitem> Albumtype = new list<fineui.listitem> ();
foreach (Demandstatus type in Enum.getvalues (typeof (Demandstatus)))
{
Albumtype.add (New Fineui.listitem (type. ToString (), ((int) type). ToString ()));
}
This.ddl_status. DataSource = Albumtype;
This.ddl_status. DataTextField = "Text";
This.ddl_status. DataValueField = "Value";
This.ddl_status. DataBind ();
For example, here the binding enumeration to 1 DropDownList is a traversal of the ' demandstatus ' value in this enumeration is used
And in general, it just needs to be used directly.
Demandstatus. Normal
There is also the need to use the <%# GetDate ("status") if the value of the database encountered in development needs to be replaced by your enumeration%>
To bind in turn
Protected string GetDate (string status)
{
foreach (Productstatus item in Enum.getvalues (typeof (Productstatus)))
{
if (Convert.ToInt32 (status) = = Convert.ToInt32 (item))
{
return item. ToString ();
}
}
return string. Empty;
}
Silently note the various usages of enumerations