无刷新联动二级菜单 20

页面代码:<HTML><HEAD><title>test</title><metaname="GENERATOR"Content="MicrosoftVisualStud... 页面代码:
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 88px; POSITION: absolute; TOP: 168px"
runat="server" Width="192px" DataTextField="Menu" DataValueField="TID"></asp:DropDownList>
<asp:label id="Label1" style="DISPLAY:none" runat="server">Label</asp:label>
<asp:DropDownList id="DropDownList2" style="Z-INDEX: 102; LEFT: 368px; POSITION: absolute; TOP: 168px"
runat="server" Width="176px" DataTextField="LMenu" DataValueField="LID"></asp:DropDownList>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 208px; POSITION: absolute; TOP: 264px" runat="server"
Text="Button"></asp:Button>
</FONT>
</form>
<script LANGUAGE="javascript">
//将隐藏的字符串取出来,然后分割到一个数组中去
var str = document.getElementById("Label1").innerText;
arr=str.split(",");
a=arr.length
ar=new Array()
for (i=0;i<a;i++){
ar[i]=arr[i].split("-");
}
onecount=ar.length;

//此处实现联动
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>
cs代码:
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
}
//给DropDownList1设置onchange事件
DropDownList1.Attributes.Add("onchange","ld();");

//1
dc.Connect(strconn);
string mysql="select TID,Menu from TopMenu";
DataSet ds=dc.ReturnDataSet(mysql,"TopMenu");
DropDownList1.DataSource=ds.Tables["TopMenu"];
DropDownList1.DataBind();
dc.Disconnect();

//2
dc.Connect(strconn);
SqlCommand cm=dc.ReturnCommand();
cm.CommandType=CommandType.StoredProcedure;
cm.CommandText="A_GetRank1";
cm.Parameters.Add("@Flag",SqlDbType.Int);
cm.Parameters["@Flag"].Value=6;
SqlDataAdapter da = new SqlDataAdapter(cm);
DataSet ds1 = new DataSet();
da.Fill(ds1,"LeftMenu");

dc.Disconnect();

Label1.Text="";
foreach(DataRow row in ds1.Tables["LeftMenu"].Rows)
{
Label1.Text = Label1.Text + row["TID"] + "-" +row["LID"] + "-"+row["LMenu"] + ",";

}

功能已经实现了,但我不知道怎么来获取页面上
2个dropdownlist的值,请问我应该怎么来获取?
谢谢
展开
 我来答
百度网友af89f4f2d
2006-01-04
知道答主
回答量:1
采纳率:0%
帮助的人:0
展开全部
.cs文件里用
Request.Form[]获取试试
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式