| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 919 人关注过本帖
标题:DropDownList控件调用onselectedindexchanged事件无效
取消只看楼主 加入收藏
暗尘
Rank: 2
等 级:论坛游民
帖 子:22
专家分:37
注 册:2011-9-15
结帖率:25%
收藏
已结贴  问题点数:20 回复次数:0 
DropDownList控件调用onselectedindexchanged事件无效
前台代码:
<td width="75%">
<asp:DropDownList ID="address_sheng" runat="server" CssClass="areacss"
AutoPostBack="true"
onselectedindexchanged="address_sheng_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="address_city" runat="server" CssClass="areacss">
</asp:DropDownList>
</td>
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetCoures();
//事件注册
// this.address_sheng.SelectedIndexChanged += new System.EventHandle(this.address_sheng_SelectedIndexChanged);
}

}
public void GetCoures()
{
this.address_sheng.DataSource = new B_City().getarr(1);
this.address_sheng.DataValueField = "C_Sid";
this.address_sheng.DataTextField = "C_name";
this.address_sheng.DataBind();
ListItem li = new ListItem("--请选择--", "0");
this.address_sheng.Items.Insert(0, li);
GetCity();
}
public void GetCity()
{
ListItem li = new ListItem("--请选择--", "0");
this.address_city.Items.Insert(0, li);
}
void address_sheng_SelectedIndexChanged(object sender, EventArgs e)
{
int sid =Convert.ToInt32(this.address_sheng.SelectedValue);
this.address_city.DataSource = new B_City().getAll_city(sid);
this.address_city.DataValueField = "C_id";
this.address_city.DataTextField = "C_name";
this.address_city.DataBind();
ListItem li = new ListItem("--请选择--", "0");
this.address_city.Items.Insert(0, li);
}
根据断点调试可知:当address_sheng的value值发生改变时向服务器发布了请求 只不过是Page_Load页面刷新 并木有调用address_sheng_SelectedIndexChanged方法
搜索更多相关主题的帖子: asp server 
2013-02-19 14:45
快速回复:DropDownList控件调用onselectedindexchanged事件无效
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020987 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved