枚举绑定到DropDownList

        /// <summary>
        /// 将GPS绑定到DropDownList
        /// </summary>
        private void BindGPS()
        {
            this.dropGPS.Items.Clear();
            dropGPS.DataSource = ListGPS();
            dropGPS.DataValueField = "value";
            dropGPS.DataTextField = "text";
            dropGPS.DataBind();
        }

        public static IList ListGPS()
        {
            ArrayList list = new ArrayList();
            foreach (int i in Enum.GetValues(typeof(GPS)))
            {
                ListItem listitem = new ListItem(Enum.GetName(typeof(GPS), i), i.ToString());
                list.Add(listitem);
            }
            return list;
        }

你可能感兴趣的:(list)