This article introduces the use of enumerations in the development of ASP. Contains an enumeration of the values that display the enumeration and an example description of the two functions enumerated for the drop-down box binding.
1 Displays the value of the enumeration: <%# (CN80s.DDPM.Model.Enum.EnumBidCardStatus) (int) Eval ("Perpaidcard_status")%>
2 binding Enumerations for drop-down boxes:
Getenumlist (Ddlbids); void Getenumlist (DropDownList ddl) {foreach (Enumbidcardtype s in System.Enum.GetValues (typeof (Enumbidcardtype))) {DDL . Items.Add (New ListItem (S.tostring (), ((int) s). ToString ())); }} This.ddlBids.DataSource = Getenumlist (typeof (Enumbidcardtype), true); This.ddlBids.DataTextField = "Text"; This.ddlBids.DataValueField = "Value"; This.ddlBids.DataBind (); public static list<listitem> getenumlist (Type enumtype, bool allalloption) {if (Enumtype.isenum = = False) {return Null } list<listitem> List = new list<listitem> (); if (allalloption = = true) {list. ADD (New ListItem ("--All--", ""));} Type typedescription = typeof (DescriptionAttribute); system.reflection.fieldinfo[] fields = Enumtype.getfields (); String strText = String. Empty; String strvalue = String. Empty; foreach (FieldInfo field) {if field. Isspecialname) continue; strvalue = field. Getrawconstantvalue (). ToString (); object[] arr = field. GetCustomAttributes (Typedescription, true); If (arr.) Length > 0) {strText = (arr[0] as DescriptionAttribute). Description; } else {strText = field. Name; } list. ADD (New ListItem (StrText, strvalue)); } return list; }