dropdownlist 联动思路

  protected void Page_Load(object sender, EventArgs e)
    {if(!IsPostBack){
        userinfor user = new userinfor();
        DataSet ds = user.arealist();
        Drlarea.DataSource = ds.Tables[0].DefaultView; Drlarea.DataTextField = "P_areaname";
        Drlarea.DataValueField = "ID";
        Drlarea.DataBind();
        DataSet ds2 = user.classlist();
        Drlclass.DataSource = ds2.Tables[0].DefaultView;
        Drlclass.DataTextField = "P_productclass";
        Drlclass.DataValueField = "ID";
        Drlclass.DataBind();
        Drlclass.Items.Insert(0,new ListItem("请选择分类"));
        Drpnext.Items.Insert(0, new ListItem("请选择子分类"));

}
    }
    protected void Drlclass_SelectedIndexChanged(object sender, EventArgs e)
    {
        int ID =Convert .ToInt32(Drlclass.SelectedValue);
        userinfor user = new userinfor();
        DataSet ds = user.classnextlist(ID);
        Drpnext.DataSource = ds.Tables[0].DefaultView;
        Drpnext.DataTextField = "P_nextclass";
        Drpnext.DataValueField = "ID";
        Drpnext.DataBind();

    }

 

 

你可能感兴趣的:(list)