给个列子好吗?

解决方案 »

  1.   

    前台:  <asp:DropDownList ID="Drop_duty" runat="server">
                    </asp:DropDownList>后台:/// <summary>
            /// 绑定分类下拉框
            /// </summary>
            private void DropTree()
            {
                Drop_duty.Items.Clear();
                Drop_duty.Items.Add(new ListItem("请选择", "0"));
                try
                {
                    DataTable dttype = new BLL.cp_newstype().GetList(0, "newst_pid=0 and newst_type=1", "newst_order asc,newst_id desc").Tables[0];
                    for (int i = 0; i < dttype.Rows.Count; i++)
                    {
                        Drop_duty.Items.Add(new ListItem(dttype.Rows[i]["newst_name"].ToString(), dttype.Rows[i]["newst_id"].ToString()));
                        DataTable dtpid = new BLL.cp_newstype().GetList(0, "newst_pid=" + dttype.Rows[i]["newst_id"].ToString() + " and newst_type=1", "newst_order asc,newst_id desc").Tables[0];
                        for (int j = 0; j < dtpid.Rows.Count; j++)
                        {
                            Drop_duty.Items.Add(new ListItem(" " + "|--" + dtpid.Rows[j]["newst_name"].ToString(), dtpid.Rows[j]["newst_id"].ToString()));
                        }
                    }
                }
                catch
                {
                    ;
                }
            }
    也就是两个for循环! 比如  两级菜单   先帮定第一级   然后for循环   每循环一次把id传给下一个循环  以此类推!
    不懂的你可以在问我!
      

  2.   


            <optgroup label="奔驰">
                <option>奔驰A</option>
                <option>奔驰B</option>
                <option>奔驰C</option>
            </optgroup>
    为什么不看他代码
      

  3.   

    样式好看得采用Div模拟Select的方式来做
      

  4.   

    个人觉得这个才是比较好的做法html本来就有
      

  5.   

    datalist 绑定分级数据库,完全可以实现你要的效果。