一个按钮响应的问题
一个按钮
<asp:Button ID="Btnquery" runat="server" Text="查询" OnClick="Btnquery_Click" />
它提交的是,多条件查询(Textbox),但是点击查询按钮后,总是无法执行Btnquery_Click(),设置断点也到不了那里,而是直接执行
Page_Load就停止了,导致在后台.cs中就无法得到Textbox的值,不知道是什么原因。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//BindGridView(); //如果放在这里就能够执行,但是得不到点击按钮前填入的值。
}
}
private void BindGridView()
{
SQLHelper sql = new SQLHelper();
DataSet dt = new DataSet();
string strSql = "select * from GeomDf where 1 = 1";
if (this.dateinput1.Text != "")
strSql += " and rundate1 = '" + this.dateinput1.Text + "'";
if (this.dateinput2.Text != "")
strSql += " and rundate2 = '" + this.dateinput2.Text + "'";
sql.RunSQL(strSql, ref dt);
GridView1.DataSource = dt.Tables[0];
GridView1.DataBind();
}
protected void Btnquery_Click(object sender, EventArgs e)
{
BindGridView();
}
代码如上,不知道为何就不能执行,要是如注释写的那样放在page_load中就能执行,但是放在page_load中就得不到点击按钮前输入的值。不知道问题出在什么地方。
谢谢了~
应该怎么改才能实现这个多条件查询呢