如何把两个dropdownlist做关联! 我有两个dropdownlist,都是显示1到24的数字,直接写到里面的.我现在想如果第一个选择8的话,第二个就不能选择8和8以前的数字,请大家指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果服务器控件做的话,很简单啊.第一个ddl设置为AutoPostBack="True",然后在SelectedIndexChanged事件里面绑定第二个ddlfor(int i = this.dropdownlist1.SelectedValue;i<24;i++){ //这个添加dropdownlist1的项} 可以用javascript编写一个;如果是服务器控件只需要添加一个事件就可以了 先把两个都加上同样的项把第一个的AutoPostBack设为true在事件中判断,如果第一个选了删除第二个里面的项:dropdownlist2.Items.RemoveAt(dropdownlist1.selecteditem.vale); 根据第一个dropdownlist的SelectedIndexChanged事件将第一个dropdownlist的SelectedValue的值或者SelectedItem作为查询的对象传给DropDownList2,DropDownList2根据值再绑定把第一个的AutoPostBack设为true protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { int sValue = int.Parse(this.DropDownList1.SelectedValue); int s2Value; for (int i = 0; i < this.DropDownList2.Items.Count;i++ ) { s2Value = int.Parse(this.DropDownList2.Items[i].Value); if (s2Value <= sValue) { this.DropDownList2.Items[i].Enabled = false; } } } 不是我懒,是真的没有找到解决办法,你最后的代码中的item的enabled属性根本就没有! 如果没有,那就把第二个dropdownlist 的 item清掉,自己增加小于第一个seletedvalue的item SQL注入 了解ArcGis的进来 用WCF创建Webservice 高分在线等 firefox获取iframe的document对象 createElement問題,請教高手. 判断用户名和密码是否正确(ASP.NET). 请问?Int((DataView.Count+9)\10)是什么意思? 精通asp与asp.net的请帮忙 求助:页面刷新和重定向 用户登陆的代码有错 求助:一个关于绑定按钮列弹出新页面的问题~百分相赠! 关于Repeate控件,能否实现跟GridView那种直接在当前页对记录进行修改?
第一个ddl设置为AutoPostBack="True",然后在SelectedIndexChanged事件里面绑定第二个ddl
for(int i = this.dropdownlist1.SelectedValue;i<24;i++)
{
//这个添加dropdownlist1的项
}
把第一个的AutoPostBack设为true在事件中判断,如果第一个选了删除第二个里面的项:
dropdownlist2.Items.RemoveAt(dropdownlist1.selecteditem.vale);
将第一个dropdownlist的SelectedValue的值或者SelectedItem作为查询的对象传给DropDownList2,
DropDownList2根据值再绑定
把第一个的AutoPostBack设为true
{
int sValue = int.Parse(this.DropDownList1.SelectedValue);
int s2Value;
for (int i = 0; i < this.DropDownList2.Items.Count;i++ )
{
s2Value = int.Parse(this.DropDownList2.Items[i].Value);
if (s2Value <= sValue)
{
this.DropDownList2.Items[i].Enabled = false;
}
}
}
自己增加小于第一个seletedvalue的item