注册 登录
编程论坛 ASP.NET技术论坛

帮忙看一下这个问题

lmyh5201 发布于 2008-10-17 13:37, 819 次点击
private void Bind_Catalog()
    {
        string whereclause = "parent_type=12";
        DataSet ds = Data_SystemClass.SystemClass_select_set(whereclause,null);
        if (ds.Tables[0].Rows.Count > 0)
        {
            ddl1.DataSource = ds.Tables[0];
            ddl1.DataTextField = "type_name";
            ddl1.DataValueField = "current_type";
            ddl1.DataBind();
            ddl1.Items.Insert(0,"请选择...");
        }

    }
    protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddl1.SelectedItem.Value == "请选择...")
        {
            ddl2.Items.Clear();
            ddl2.Items.Insert(0, "请选择...");
        }
        else
        {
            string businessType = "";
            string whereclause = "parent_type=12";
            SqlDataReader dr = Data_SystemClass.SystemClass_select(whereclause, null, "businessType");
            if (dr.Read())
            {
                businessType = dr["businessType"].ToString();
                string[] arr = businessType.Split('|');
                for (int i = 1; i <= arr.Length; i++)
                {
                    string whereclause1 = "current_type=" + arr[i];
                    DataSet ds = Data_SystemClass.SystemClass_select_set(whereclause1, null);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        ddl2.DataSource = ds.Tables[0];
                        ddl2.DataTextField = "type_name";
                        ddl2.DataValueField = "current_type";
                        ddl2.DataBind();
                    }
                }
            }
        }
    }

<asp:DropDownList ID="ddl1" runat="server" OnSelectedIndexChanged="ddl1_SelectedIndexChanged">              
              </asp:DropDownList>
当我改变ddl1的选择项时,怎么不触发ddl1_SelectedIndexChanged这个事件啊?

[[it] 本帖最后由 lmyh5201 于 2008-10-17 13:49 编辑 [/it]]
2 回复
#2
ruanjian21102008-10-17 13:55
把ddl1属性中的AutoPostBack设为True。。
#3
kevintang2008-10-17 14:04
楼上正解
1