//此处实现联动 function ld() { document.Form1.DropDownList2.length=0 lid=Form1.DropDownList1.value; for (i=0;i<onecount;i++) { if (ar[i][0] == lid) { document.Form1.DropDownList2.options.add(new Option(ar[i][2], ar[i][1])); } } }
function showMsg() { alert(document.Form1.DropDownList1.value); alert(document.Form1.DropDownList2.value); }
</script> </body> </HTML>
以下是WebForm1.aspx.cs
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.sessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls;
//取出二级栏目数据,存放到一个DataTable()中 strSql = "select * from custom.smallcalling;"; da = new System.Data.SqlClient.SqlDataAdapter(strSql,strConn); tb1 = new DataTable(); da.Fill(tb1);