DropDownList ddlist = new DropDownList();
            ddlist.ID = "proddllist" ;
            ddlist.ddlist.AutoPostBack = true;
 那AutoPostBack 执行的函数该怎么添加呢?

解决方案 »

  1.   

        protected void Button1_Click(object sender, EventArgs e)
        {
            DropDownList ddlist = new DropDownList();
            ddlist.ID = "proddllist";
            ddlist.AutoPostBack = true;
            ddlist.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged);
           
        }
       
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {    }
      

  2.   

    ddlist.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged);
      

  3.   

    如果是增加JS事件
    你依然可以在前台代码中写入静态的,也可以在后台PageLoad时加入,例如我给DropDownList加个Onclick事件:DropDownList1.Attributes("onclick", "function{}//JS方法名");
    而服务端事件,如几位楼上所说的方法,但是在VS2005中,
    DropDownList1.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged);似乎是没必要自己写,由平台自动会给你建立,前提是你的AutoPostBack 设为了True
      

  4.   

    用(DropDownList)findcontrol(ddID)来操作该dropdownlist
      

  5.   

    ddlist.SelectedIndexChanged += delegate(object sender, EventArgs e){//Code here};
      

  6.   

    想偷懒也可以使用
     ddlist.SelectedIndexChanged += delegate { Response.Write(ddlist.SelectedItem.Text); };