我打算用一个下拉列表框控件,把数组的东西显示出来,怎么不行啊:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="storeage.aspx.cs" Inherits="test.storeage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        protected String[] MyStates = { "AK", "AL", "AR" };
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">
    <title>无标题页</title>
     <link id="Link1" rel="Stylesheet" type="text/css" href="ex1.css" runat="server" />
  
</head>
<body>
  
    <form id="form1" runat="server">
    <asp:DropDownList ID="DropDownList1" runat="server" DataSource="<%#MyStates %>">
    
    </asp:DropDownList>
    </form>
  
</body>
</html>  protected void Page_Load(object sender, EventArgs e)
        {            DropDownList1.DataBind();
        }

解决方案 »

  1.   

    MyStates  怎么定义的?
    断点跟踪下,是否是控制,在看下arraylist 是否继承了接口Ilist,如果继承,肯定可以的
      

  2.   

    楼主应该用for循环来依次加入到dropdownlist中;for(int i= 0;i< arraylist.count;i++){
    dropdownlist.items.add(arrlist[i].tostring());
    }应该就可以了。
      

  3.   

    不要用字符串数组,用ArrayList即可实现或自己写个类,实现相应接口
      

  4.   

    我直接这样子也可以搞定,是不是太偷懒了? 
     protected void Page_Load(object sender, EventArgs e)
            {
                Trace.Write("In page_load");
                string[] delivery = { "Post", "Courier", "International" };
                ListBox1.DataSource = delivery;
                ListBox1.DataBind();
            }