有个分类表(如手表、香水、箱包等),还有个品牌表(如古驰、巴宝莉等),一个品牌可以在多个类型下
在选择分类后,出现分类下面的品牌,注意数据都是从数据库读取的

解决方案 »

  1.   

    那你就从数据库中读取贝我一般是在后台写代码!
    第一步,找到你的所有品牌,放在第一个dropdownlist中
    在根据选择第一个dropdownList的Id去查找,来显示在第二个dropdownList当中的值!这个两级联动很简单的哎!
    你代码写出来,直接绑定一下就可以了啊!
      

  2.   

    前台 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script language="javascript" type="text/javascript">
            var xhr;
            var num;
            function CreateXmlHttp() {
                if (window.ActiveXObject) {
                    xhr = new ActiveXObject("Microsoft.XMLHTTP");
                }
                else {
                    xhr = new XMLHttpRequest();
                }
            }
            function SendReq() {
                CountryID = document.getElementById("Country").value;
                CreateXmlHttp();
                var url = "Test.ashx?CountryID=" + CountryID;
                xhr.open("GET", url, true);
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4 && xhr.status == 200) {
                        var result = xhr.responseText;
                        document.getElementById("City").innerHTML = result;
                    }
                }
                xhr.send(null);
            }
        </script>
    </head>
    <body>
        <select id="Country" onchange="SendReq()">
            <option value="1">中国</option>
            <option value="2">美国</option>
        </select>
        <span id="City"></span>
    </body> 
    </html>
    后台
    <%@ WebHandler Language="C#" Class="Test" %>using System;
    using System.Text;
    using System.Web;
    using System.Data;
    using System.Data.SqlClient;public class Test : IHttpHandler {
        public void ProcessRequest (HttpContext context) 
        {
            context.Response.ContentType = "text/plain";
            StringBuilder builder = new StringBuilder();
            if (context.Request.QueryString["CountryID"]!=null)
            { 
                builder.Append("<select>");
                int countryID = int.Parse(context.Request.QueryString["CountryID"]);
                string sqlCn = "Data Source=.;Initial Catalog=Test;Integrated Security=True;";
                //根据国家编号查询数据表中的城市编号,城市名
                string sqlCmd = "select CityID,CityName from City Where CountryID="+countryID;
                //根据前台的请求 查询需要的数据
                using (SqlConnection cn = new SqlConnection(sqlCn))
                {
                    SqlCommand cmd = new SqlCommand(sqlCmd,cn);
                    cn.Open();
                    SqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        builder.Append("<option value='"+dr["CityID"].ToString()+"'>"+dr["CityName"].ToString()+"</option>");
                    }
                    dr.Close();
                    builder.Append("</select>");
                }
            }
            //返回前台请求的数据
            context.Response.Write(builder.ToString());
        }
     
        public bool IsReusable 
        {
            get {
                return false;
            }
        }}
      

  3.   


    上个帖有给你回过了http://blog.csdn.net/porschev/archive/2010/10/15/5943579.aspx可以把这个改一下。。但是形式己经出来了