Enum 作为一个数据源绑定(收藏)

 

一个DropDwon和ListBox 绑定一个Enum的示例:代码如下所示:

1.选创一个Enum:

enum Speen
        { Low = 1, Mdeim = 2, High = 3 }

2.绑定数据:

protected void Page_Load(object sender, EventArgs e)
      {
          DropDownList1.DataSource = Enum.GetValues(typeof(Speen));
          DropDownList1.DataBind();
          ListBox1.DataSource = Enum.GetValues(typeof(Speen));
          ListBox1.DataBind();
      }

3.运行结果如下:

image

原文地址:http://www.cnblogs.com/caodaiming/archive/2009/04/23/1442397.html

posted @ 2009-04-23 22:40  温景良(Jason)  Views(378)  Comments(0Edit  收藏  举报