请问如何在asp.net中用服务器控件DropDownList,做静态的二级联动的 DropDownList不能使用DropDownList 的AutoPostBack 属性.主要使用Javascript谢谢!

解决方案 »

  1.   

    Ajax 搜索这个主题,你会找到答案的
      

  2.   

    具体如下:
    <html>
      <head>
      <title>后台产品添加</title>
      <meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
    <link href="../../../INC/Style.Css" rel="stylesheet" type="text/css">
    <script language = "JavaScript">
      var onecount;
      onecount=0;
      subcat = new Array();
       <%
       int count = 0;
       rs = Conn.executeQuery("select * from ego_smallsort order by Sid");//读取数据
      while(rs.next())
      {
      String sname=new String(rs.getString("Sname").getBytes("GBK"),"ISO8859_1");//转换字符类型
      %>
      subcat[<%=count%>] = new Array("<%=sname%>","<%=rs.getInt("Bid")%>","<%=rs.getInt("Sid")%>");//产生数组
      <%
       count = count + 1;
      }
      %>
      onecount=<%=count%>;
    function changelocation(id)
       {
       document.form1.smallsortselect.length = 0;
    var id=id;
       var i;
       document.form1.smallsortselect.options[0] = new Option('选择二级分类','');
       for (i=0;i < onecount; i++)
       {
       if (subcat[i][1] == id)
       { 
       document.form1.smallsortselect.options[document.form1.smallsortselect.length] = new Option(subcat[i][0], subcat[i][2]);
       } 
       }
       
       } 
       
      </script>
      </head>
      <body bgcolor="#FFFFFF">
    <form name="form1" method="post" action="">
      <table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
       <tr>
       <td width="180" height="20" align="right">选择一级分类:</td>
       <td width="320">
       <select name="bigsortselect" onChange="changelocation(document.form1.bigsortselect.options[document.form1.bigsortselect.selectedIndex].value)" size="1">
       <option value="2">请选择一级分类</option>
      <%
       rs = Conn.executeQuery("select * from ego_bigsort order by Bid");
      while(rs.next())
      {
       String Bname = new String(rs.getString("Bname").getBytes("GBK"),"ISO8859_1");
       System.out.println(Bname);
      %>
       <option value="<%=rs.getInt("Bid")%>"><%=Bname%></option>
      <%
      }
      %>
       </select><br>
      

  3.   

    我也遇到这个问题,使用AJAX可以实现页面上的无刷新效果,但后台.ASPX.CS文件
    取不到页面的值!
    无论页面上的数据怎样变动,后台总是取得第一项的值!!
      

  4.   

    AJAX取不到值?不会吧
    我一直在用的啊,怎么会取不到值呢?是不是你方法不对啊!