求asp.net 数据库绑定无限级联下拉框(无刷新,注:当选着父级时,有子级的话就显示子级的新下拉框,没有的话就不显示!))

解决方案 »

  1.   

    JS+AJAX....动态生成下拉列表框。
      

  2.   

    不用js也可以,只用Ajax;不过要写在下拉菜单的事件;
      

  3.   

    ajax 控件 updatepanel 
      

  4.   

    public class DDLDepartment : DropDownList
      {
        
      public DDLDepartment()
      {
      bind(this, 0);
      this.Items.Insert(0, new ListItem("==请选择==", ""));
      }  public void bind(DropDownList ddlDepartment, int parent)
      {
      IList<Department> deptlist = DepartmentBLL.SelectChild(parent);
      foreach (Department dept in deptlist)
      {
      string text = new string(' ', dept.Depth - 1);
      text += "└" + dept.DeptName;
      ddlDepartment.Items.Add(new ListItem(text, dept.DeptId.ToString()));
      bind(this, dept.DeptNo);
      }
        
      }
      }dropdownlist联动
    <asp:ScriptManager ID="ScriptManager1" runat="server">
      </asp:ScriptManager>
      <div>
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
      <ContentTemplate>
      <asp:DropDownList ID="ddlLB" runat="server" Width="15%" AutoPostBack="True" OnSelectedIndexChanged="ddlLB_SelectedIndexChanged">
      </asp:DropDownList>
      <asp:DropDownList ID="ddlChild" runat="server" Width="20%">
      </asp:DropDownList>
      </ContentTemplate>
      </asp:UpdatePanel>
      </div>   
    protected void ddlLB_SelectedIndexChanged(object sender, EventArgs e)
      {
      if(this.ddlLB.SelectedValue!=null)
      {  }
      }
      

  5.   

    好像有个是4级的,不是无限级的;原理一样的;判断之后是否new DropDownList()对象;