问题描述:datecheckbox  dateTextBox
FLightCheckBox FlightTextBox
      linkButton链接页:输出数据库的flight的gridview表格,查询条件为checkbox所选值,可以按date查询,可以按Flight查询,或两者一起查询
请问如何实现??
是Sessison吗??

解决方案 »

  1.   

    string sql=select * from Tb where 1=1";
    sql+=datecheckbox.Checked?" and 1=1":"";
      

  2.   

    一般情况下用sql多条件查询时这样的:select * from table where  a=x and b=y但是要动态粘贴select * from table 后面的条件却多出来个where所以此时我一般加个where
    1=1然后在sql句子select * from table where 1=1 后面直接执行:sql+="  and a=x";sql+=" and b=y"就可以了。正如楼上人生如梦所展示的