我正在構建它是其中一部分的複雜問題的一個簡單示例。將值與c中的枚舉進行比較#
爲了方便起見,有一個下拉列表,充滿了一年中的幾個月。
BindDropDown()
{
ddlColors.DataSource = GetAllMonths();//Returns a List<string> with months
ddlColors.DataBind();
//note the drop down only have data fields no value fields no corresponding numeric values of the months.
}
public enum Months
{
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December = 12
}
從下拉選擇任何一個月份中下來後我有一些能得到相應的數值如何與存儲其數值枚舉匹配。
例如:從下降值下降是五月,因此其對應的數字部分5.
從數據庫中,這將是數字,我一些如何必須得到枚舉的文本部分獲得價值之後。
例如:來自數據庫的值是5,所以其相應的文本部分可能是5。
何我能否實現上述場景?
這將幫助你 - [http://stackoverflow.com/questions/5129378/enums-and-combo-boxes-in-c-sharp?rq=1][1] [1]:http://stackoverflow.com/questions/5129378/enums-and-combo-boxes-in-c-sharp?rq=1 – Jardalu