this.Month.Items.Add(new ListItem("January","1")

解决方案 »

  1.   

    //定义一个DropDownListData类
    public class DropDownListData
    {
    private string _text;
    private string _value; public TabItem(string newText, string newValue)
    {
    _text = newText;
    _value = newValue;
    } public string Text
    {
    get { return _text;}
    set { _text = value;}
    } public string Value 
    {
    get { return _value ; }
    set { _value = value; }
    }
    }//帮定数据
    ArrayList DropDownListDatas= new ArrayList();DropDownListDatas.Add(new DropDownListData("January", "1" ));
    ...
    DropDownList1.DataSource = DropDownListDatas;
    DropDownList1.DataBind();
      

  2.   

    sorry,有个地方(构造函数)写错了//定义一个DropDownListData类
    public class DropDownListData
    {
    private string _text;
    private string _value; public DropDownListData(string newText, string newValue)
    {
    _text = newText;
    _value = newValue;
    } public string Text
    {
    get { return _text;}
    set { _text = value;}
    } public string Value 
    {
    get { return _value ; }
    set { _value = value; }
    }
    }//帮定数据
    ArrayList DropDownListDatas= new ArrayList();DropDownListDatas.Add(new DropDownListData("January", "1" ));
    ...
    DropDownList1.DataSource = DropDownListDatas;
    DropDownList1.DataBind();
      

  3.   

    string[] strMonth = new string[]{"January","Feburary",..."December"};
    for (int i=1;i<= 12; i++)
    {
    ListItem item = new ListItem(strMonth[i],i);
    this.Month.Items.Add(item);
    }