前台页面放置一个GridView和一个TextBox 还有一个提交按钮  数据源是 SqlDataSource


后台在PAGE_LOAD 默认的数据源是:

this.SqlDataSource.selectcommand="select * from table";

当我在TextBox里面写入查询条件的时候提交 数据源变成了
(下面是提交按钮的事件)

PUBLIC VOID BTN_CLICK(ODJECT SENDER,.........)
{
this.SqlDataSource.selectcommand="select * from table  where users_name="+TextBox.text;
 }

提交后数据显示正常  但是当我翻页的时候 数据源又自动变回原来的拉(因为PAGE_LOAD事件又发生了)


我只好又在PAGE_LOAD里加一个判断语句(很不高明)

if(TextBox1.text!="")

{

this.SqlDataSource.selectcommand="select * from table  where users_name="+TextBox.text;

}


请问有什么高明的好办法代替这么做吗>? 谢谢

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-12-17
  • 2023-01-11
  • 2021-06-01
  • 2021-07-11
  • 2022-01-12
猜你喜欢
  • 2022-12-23
  • 2022-01-16
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
相关资源
相似解决方案