问题描述
如题,我自己做了,但是DropDownListRoomState_SelectedIndexChanged事件里面一条语句都不会执行,附上完整代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data;usingSystem.Data.SqlClient;namespaceWebApplication1.houtaiasp{publicpartialclassCheckIn:System.Web.UI.Page{DataConnectdata=newDataConnect();protectedvoidPage_Load(objectsender,EventArgse){//获取入住号SqlConnectionconnID=data.GetConn();//新建链接try{stringsql1="selectMAX(RUZHU_ID)+1fromruzhukefang";//定义查询入住表中最大的入住号并且+1SqlCommandcmd1=newSqlCommand(sql1,connID);SqlDataReadersdr=cmd1.ExecuteReader();if(sdr.Read())//是否读到数据{this.TextBoxCheckInID.Text=sdr.GetValue(0).ToString();//若读到数据,将数据赋值给TextBoxCheckInID}connID.Close();//关闭数据库连接sdr.Dispose();//释放sdrsdr.Close();//关闭sdr}catch(Exceptionee){Response.Write(ee.ToString());//返回异常信息}//获取可入住状态下的客房ID,并且根据客房ID获取房间类型SqlConnectionconn=data.GetConn();//新建链接try{stringstrsql="selectR_IDfromguestroomwhereR_STATE='可入住'";SqlCommandscm=newSqlCommand(strsql,conn);SqlDataReadersdr=scm.ExecuteReader();DropDownListRoomState.DataTextField="R_ID";DropDownListRoomState.DataValueField="R_ID";DropDownListRoomState.DataSource=sdr;DropDownListRoomState.DataBind();stringsql2="selectR_TYPEfromguestroomwhereR_ID="+this.DropDownListRoomState.SelectedValue;SqlConnectionconn2=data.GetConn();SqlCommandcmd2=newSqlCommand(sql2,conn2);SqlDataReadersdr2=cmd2.ExecuteReader();if(sdr2.Read()){this.LabelRoomType.Text=sdr2[0].ToString();}else{this.LabelRoomType.Text="已经没有客房了";}}catch(Exceptioneee){Response.Write(eee.ToString());//返回异常信息}//获取当前登陆者身份,赋值给处理员工字段objectlogined=Session["logined"];if(logined==null){this.Labelyuangong.Text="";}else{if(logined.ToString().Equals("OK1")){this.Labelyuangong.Text=Session["username"].ToString();;//获取当前登陆者姓名,赋值给Labelyuangong}else{this.Labelyuangong.Text="";}}}protectedvoidDropDownListRoomState_SelectedIndexChanged(objectsender,EventArgse)//在DropDownListRoomState选择一个项之后触发的事件,显示当前客房号对应的客房类型(不会局部刷新,这功能没做好){this.LabelRoomType.Text="啦啦啦";//这句没执行stringsql2="selectR_TYPEfromguestroomwhereR_ID="+this.DropDownListRoomState.SelectedValue;SqlConnectionconn2=data.GetConn();SqlCommandcmd2=newSqlCommand(sql2,conn2);SqlDataReadersdr2=cmd2.ExecuteReader();if(sdr2.Read()){this.LabelRoomType.Text=sdr2[0].ToString();}else{this.LabelRoomType.Text="已经没有客房了";}}protectedvoidButtonSure_Click(objectsender,EventArgse)//确认按钮事件{stringruzhuid,cusname,cussex,cusminzu,cusidcard,roomid,checkintime,handleemployee;//进行赋值操作ruzhuid=this.TextBoxCheckInID.Text.Trim();//入住ID,便于编号,方便记录cusname=this.TextBoxCusName.Text.Trim();//客户姓名cussex=this.DropDownListCusSex.SelectedValue;//客户性别cusminzu=this.TextBoxCusminzu.Text.Trim();//客户民族cusidcard=this.TextBoxCusIdCard.Text.Trim();//客户身份证号roomid=this.DropDownListRoomState.SelectedValue;//所入住客房号checkintime=this.TextBoxCheckTime.Text.Trim();//入住时间handleemployee=this.Labelyuangong.Text;//经办员工//定义更新语句stringinstr="insertintoruzhukefangvalues('"+ruzhuid+"','"+cusname+"','"+cussex+"','"+cusminzu+"','"+cusidcard+"','"+roomid+"','"+checkintime+"','"+handleemployee+"')";SqlConnectionconninsert=data.GetConn();SqlCommandcmdinsert=newSqlCommand(instr,conninsert);cmdinsert.ExecuteNonQuery();//执行插入语句conninsert.Close();//关闭数据库连接//下述操作是办理入住同时将入住客房状态更改为“已入住”stringupsql="updateguestroomsetR_STATE='已入住'whereR_ID="+roomid;SqlConnectionconnup=data.GetConn();SqlCommandcmdup=newSqlCommand(upsql,connup);cmdup.ExecuteNonQuery();//执行更新语句connup.Close();//关闭数据库连接Response.Redirect("CheckIn.aspx");//返回修改之前的页面}}}我的DropDownListRoomState是放在UpdatePanel2里面的,而控件LabelRoomType放在UpdatePanel1里面。我在UpdatePanel2做了这样的配置:Trrigger弄了触发器,ControlID设置的是DropDownListRoomState,就是DropDownList的ID,EventName设置的是DropDownList的SelectedIndexChanged事件,我选择了不同的DropDownList的项。但是label并没有刷新。求各位大神帮帮忙
解决方案
解决方案二:
。。。。怎么没人帮我看看啊