我用c#+asp.net,现在想把两个DropDownList关联起来,up有分
我用c#+asp.net,现在想把两个DropDownList关联起来,up有分
就是一个显示1另外一个就会显示1.1---1.9
一个显示2另外一个就会显示2.1--2.9
分不够加!!!!!!!!!
问题点数:30、回复次数:15Top
1 楼KK4(逐月)回复于 2003-11-04 07:46:17 得分 10
這應該easy
你先在DropDownlist1創建datasource
然後通過dropdownlist1中的selectindex.text的內容為dropdownlist2查詢數據源的condition即可
Top
2 楼Jack0Cao(曹龙)回复于 2003-11-04 07:56:50 得分 0
是不用刷新的那种Top
3 楼pp4u(方便面(当天结贴))回复于 2003-11-04 08:03:11 得分 10
< html >
< head >
< title >List< /title >
< meta http-equiv="Content-Type" content="text/html; c
harset=gb2312" >
< script LANGUAGE="javascript" >
< !--
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("徐汇区","01","001");
subcat[1] = new Array("嘉定区","01","002");
subcat[2] = new Array("黄浦区","01","003");
subcat[3] = new Array("南昌市","02","004");
subcat[4] = new Array("九江市","02","005");
subcat[5] = new Array("上饶市","02","006");
onecount=6;
function changelocation(locationid)
{
document.myform.smalllocation.length = 0;
var locationid=locationid;
var i;
document.myform.smalllocation.options[0] = new Option('====所有地区====','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.smalllocation.options[document.myform.smalllocation.length]
= new Option(subcat[i][0], subcat[i][2]);
}
}
}
//-- >
< /script >
< /head >
< body >
< form name="myform" method="post" >
< select name="biglocation"
onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)" >
< option value="01" selected >上海< /option >
< option value="02" >江西< /option >
< /select >
< select name="smalllocation" >
< option selected value="" >==所有地区==< /option >
< /select >
< /form >
< script LANGUAGE="javascript" >
< !--
changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value);
//-- >
< /script >
< /body >
< /html >
Top
4 楼atai2002(阿泰)回复于 2003-11-04 09:09:08 得分 0
正在关注,帮你up一下Top
5 楼littlechang(海纳百川)回复于 2003-11-04 09:24:46 得分 0
用javascript响应第一个dropdownlist的indexchange事件,应该容易实现。Top
6 楼shmyfree(我心依旧)回复于 2003-11-04 09:36:03 得分 0
帮你up
Top
7 楼shmyfree(我心依旧)回复于 2003-11-04 09:38:12 得分 0
我以前一个同学做过,好像是使用了XMLTop
8 楼Jack0Cao(曹龙)回复于 2003-11-05 10:31:07 得分 0
能用c#作么
我用的是c#+vs.net
js不熟的Top
9 楼drh84820(中国娃娃)回复于 2003-11-05 13:22:32 得分 10
<%@ Page Language="C#" %>
<script runat="server">
// Insert page code here
//
void Page_Load(object sender, EventArgs e) {
if (!IsPostBack){
ArrayList values=new ArrayList();
values.Add("in");
values.Add("ks");
values.Add("mi");
DropDownList1.DataSource=values;
DropDownList1.DataBind();
}
}
void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
switch(DropDownList1.SelectedIndex)
{
case 0:
{
ArrayList values2=new ArrayList();
values2.Add("2");
values2.Add("3");
DropDownList2.DataSource=values2;
DropDownList2.DataBind();
break;
}
case 1:
{
ArrayList values2=new ArrayList();
values2.Add("5");
values2.Add("7");
DropDownList2.DataSource=values2;
DropDownList2.DataBind();
break;
}
case 2:
{
ArrayList values2=new ArrayList();
values2.Add("q");
values2.Add("d");
DropDownList2.DataSource=values2;
DropDownList2.DataBind();
break;
}
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DropDownList id="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
<font color="white">......</font>
<asp:DropDownList id="DropDownList2" runat="server"></asp:DropDownList>
<!-- Insert content here -->
</form>
</body>
</html>
Top
10 楼drh84820(中国娃娃)回复于 2003-11-05 13:23:41 得分 0
不知这样与你的意思符不符合。Top
11 楼jeall()回复于 2003-11-05 13:43:09 得分 0
upTop
12 楼xeimm(easy(=^-^=))回复于 2003-11-05 13:56:32 得分 0
DropDownList1_SelectedIndexChanged 中国娃娃的应该是正解Top
13 楼Timothy666(Timothy666)回复于 2003-11-05 14:00:34 得分 0
写SelectedIndexChanged事件,
把autopostback设为true
Top
14 楼zhangzs8896(小二)回复于 2003-11-05 14:04:08 得分 0
DropDownList1_SelectedIndexChanged 里重新设置你的DropDownList2的DataSourceTop
15 楼hanfey()回复于 2003-11-05 14:13:08 得分 0
firstly,u must deploy on ddl "autoPostback",then
coding "SelectedIndexChanged" event to finish what u want;
Top




