日期:2014-05-18  浏览次数:20432 次

查找中关键字的问题
我有两个输入关键字的地方
按不同的按钮来区别
问题是由于绑定数据是在Page_Load
而按钮点击事件会后于Page_Load
导致即使在按钮事件设置关键字在Page_Load也使用不了
有什么方法解决

------解决方案--------------------
IsPostBack
------解决方案--------------------
<input type= "hidden " id= "h " name= "h " />
<!-- <input type= "hidden " id= "h " name= "h " runat= "server " /> -->
<input type= "button " value= "button1 " onclick= "document.all.h.value= 'button1 '; " />
<input type= "button " value= "button2 " onclick= "document.all.h.value= 'button2 '; " />

//

Page_Load()
{
string flag = this.Request[ "h "];
// string flag = this.h.value;
}
------解决方案--------------------
在你的绑定方法里把你的查询条件加上.

Page_Load()
{
if(!Page.IsPostBack)
{
BindData();
}
}

void BindData()
{
//在这里把查询条件带上
//DataGrid绑定
}

按钮事件里再调用BindData()方法