我写了一个方法,它返回的类型 
dropDownList 怎么呈现在index.aspx里呢?

解决方案 »

  1.   

    this.controls.add()不过好像不好用啊
      

  2.   

    我要方法里面生成了一个下拉菜单,要求要显示到index.aspx页上..
    不知道怎样赋值才能把它显示出来..
      

  3.   

    listitem l;
    l=new listitem();
    l.text="1";
    l.value="1";
    dropdownlist.items.add(l);
    你是不是要这样啊?
      

  4.   

    jkali() 
    不是,但我好像找到答案了.    // Create a DropDownList control.
             DropDownList DropList = new DropDownList();         // Set the properties for the DropDownList control.
             DropList.ID = "ColorList";
             DropList.AutoPostBack = true;         Place.Controls.Add(DropList);
          ICollection CreateDataSource() 
          {
          
             // Create a table to store data for the DropDownList control.
             DataTable dt = new DataTable();
             
             // Define the columns of the table.
             dt.Columns.Add(new DataColumn("ColorTextField", typeof(String)));
             dt.Columns.Add(new DataColumn("ColorValueField", typeof(String)));
     
             // Populate the table with sample values.
             dt.Rows.Add(CreateRow("White", "White", dt));
             dt.Rows.Add(CreateRow("Silver", "Silver", dt));
             dt.Rows.Add(CreateRow("Dark Gray", "DarkGray", dt));
             dt.Rows.Add(CreateRow("Khaki", "Khaki", dt));
             dt.Rows.Add(CreateRow("Dark Khaki", "DarkKhaki", dt));
     
             // Create a DataView from the DataTable to act as the data source
             // for the DropDownList control.
             DataView dv = new DataView(dt);
             return dv;      }
      

  5.   

    这个好像需要写 dropDownList 的 html到页面里才能显示出来吧。和WinForm的呈现方式不一样。