我做了个搜索,由DropDownList1,DropDownList2和button组成,先选择DropDownList1中的某项,然后自动刷新一下,使DropDownList2有数据,也就是DropDownList2的数据是动态的,随DropDownList1的项而改变,DropDownList1的AutoPostBack必须为ture,否则DropDownList2无数据.
现在的问题是点击button,不响应后面的事件,事件已经加载过了.
各位说说是什么问题,如何解决?
现在的问题是点击button,不响应后面的事件,事件已经加载过了.
各位说说是什么问题,如何解决?
解决方案 »
- 使用jQuery+ajax实现即时验证 在线等。。急..
- connection这样创建的优缺点是什么
- DataGrid ,如何才能只在某些特定的行上显示“修改”?
- 开了好几贴了,一直没有解决,取Table表中控件的值的问题
- GridView在HTML页面中如何实现数据绑定?偶是新手,急~~
- 问一个DataList绑定数据的问题!截取字符
- 关于Datagrid模板列CheckBox问题
- 如何在sqlserver存储过程中访问其他服务器上的table?
- 无法识别ASP.NET
- 一个datatable的想法,不知能否实现???
- 哪位大侠帮忙看看...标识符超出范围..
- 从数据库提出的带有〈H1〉这样标记的文本字段由于字体过大,在页面显示的时候总是重叠,怎么样处理 ?
this.Button1.Click += new System.EventHandler(this.Button1_Click);
看看是不是写错了?
在页面上重新放一个Button看能不能响应事件?
你说的问题和DropDownList没有关系
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using HLSoft.HFHouseBiz.Business.NewHouse; /// <summary>
/// Search 的摘要说明。
/// </summary>
public class HouSearch : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DropDownList Dropdownlist3;
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.DropDownList ddlDISTRICT;
protected System.Web.UI.WebControls.DropDownList ddlItem;
protected System.Web.UI.WebControls.DropDownList Dropdownlist2; private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ddlDISTRICT.SelectedIndexChanged += new System.EventHandler(this.ddlDISTRICT_SelectedIndexChanged);
this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void ddlDISTRICT_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.ddlItem.Items.Clear();
if(this.ddlDISTRICT.SelectedIndex != 0)
{
//绑定项目
DataView dv = ItemDAL.GetAllItemInfo().Tables[0].DefaultView; this.CurrentDISTRICT = this.ddlDISTRICT.SelectedValue; this.CurrentPRICE = this.Dropdownlist3.SelectedValue; string ss = CurrentPRICE; string wss="DISTRICT = '"+CurrentDISTRICT +"'";
dv.RowFilter = "DISTRICT = '"+CurrentDISTRICT +"'"; this.ddlItem.DataSource = dv;
this.ddlItem.DataTextField = "ITEM";
this.ddlItem.DataValueField = "ITEMID";
this.ddlItem.DataBind();
}
this.ddlItem.Items.Insert(0,(new ListItem("-请选择项目-","0")));
} private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
this.CurrentDISTRICT = this.ddlDISTRICT.SelectedValue;
this.CurrentPRICE = this.Dropdownlist3.SelectedValue;
string temp1 = CurrentDISTRICT;
string temp2 = CurrentLAYOUT;
string temp3 = CurrentPRICE;
string temp4 = CurrentITEMID; if(temp1 == "0" && temp2 == "0" && temp3 == "0" && temp4 == "0")
{
Response.Redirect("index.aspx");
}
else if(temp1 != "0" && temp4 != "0" && temp2=="0" && temp3=="0")
{
Response.Redirect("NewHouseItems.aspx?ITEMID="+temp4);
}
else if(temp1 != "0" && temp2 != "0" && temp3 != "0" && temp4 != "0")
{
Response.Redirect("SearchResult.aspx?CurrentDISTRICT="+temp1+"&CurrentLAYOUT="+temp2+"&CurrentPRICE="+temp3+"&CurrentITEMID="+temp4);
}
else if(temp1 != "0" && temp4 != "0" && temp2 != "0" && temp3=="0")
{
Response.Redirect("SearchResult.aspx?CurrentDISTRICT="+temp1+"&&CurrentLAYOUT="+temp2+"&CurrentITEMID="+temp4);
}
else if(temp1 != "0" && temp4 != "0" && temp3!= "0" && temp2=="0")
{
Response.Redirect("SearchResult1.aspx?CurrentDISTRICT="+temp1+"&&CurrentPRICE="+temp3+"&CurrentITEMID="+temp4);
}
else if((temp1 != "0"|| temp3 != "0" || temp4 != "0") && temp2 == "0")
{
Response.Redirect("SearchResult1.aspx?CurrentDISTRICT="+temp1+"&CurrentLAYOUT="+temp2+"&CurrentPRICE="+temp3);
}
else
{
Response.Redirect("SearchResult.aspx?CurrentDISTRICT="+temp1+"&CurrentLAYOUT="+temp2+"&CurrentPRICE="+temp3);
}
}
#region 页面属性 private string CurrentDISTRICT
{
get
{
return (string)ViewState["CurrentDISTRICT"];
}
set
{
ViewState["CurrentDISTRICT"] = value;
}
} private string CurrentLAYOUT
{
get
{
return (string)ViewState["CurrentLAYOUT"];
}
set
{
ViewState["CurrentLAYOUT"] = value;
}
} private string CurrentPRICE
{
get
{
return (string)ViewState["CurrentPRICE"];
}
set
{
ViewState["CurrentPRICE"] = value;
}
} private string CurrentITEMID
{
get
{
return (string)ViewState["CurrentITEMID"];
}
set
{
ViewState["CurrentITEMID"] = value;
}
}
#endregion }
}
是该写在if句中还是else