<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1"
Style="position: relative">
</asp:DropDownList><br />
<asp:DropDownList ID="DropDownList2" runat="server"
Style="position: relative">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
在加入了UpdatePane之后 下面的方法就不执行了protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(sqlConString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from city where proID='" + this.DropDownList1.SelectedValue.Trim() + "'", con);
SqlDataReader sdr = cmd.ExecuteReader();
this.DropDownList2.DataSource = sdr;
this.DropDownList2.DataTextField = "cityName";
this.DropDownList2.DataValueField = "cityID";
this.DropDownList2.DataBind();
sdr.Close();
con.Close();
}高手指点下...
解决方案 »
- 给THML控件赋值
- ASp.net中如何可以关闭一个打开的页面。例如“提交信息”按钮单击后本页面消失?
- win2003下iis出现Service Unavailable
- 关于三层结构各层责任的问题
- 用Command控件建立一个Access数据库
- 三个新手问题一起来....求教
- ==============小第初学Cookies,请高手指教几点cookies的用法。
- 请问能否实现这样一个较特殊的Button控件?
- [请教]SqlDataSource的update参数为空时更新失败的问题
- 请问 在DateGrid中如何实现 各行交叉显示,如第1行放表1,第2行放表2 ,
- 急求UpdatePanel中使用textbox的一个棘手问题的解答!!
- textbox为什么绑定不了数据库中取的值?
没错,DropDownList1 的 AutoPostBack="true";
还有就是楼主是不是漏了给DropDownList1 付值了??没有值不会触发SelectedIndexChanged事件的.<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>跟踪一下,就能看到执行了.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{ }