111,126
社区成员
发帖
与我相关
我的任务
分享
string sql="...";
if (checkBox1.checked)
{
sql+=" and 条件1="...;
}
if (checkBox2.checked)
{
sql+=" and 条件2="....;
}
...
定义一个全局变量
public static string lcSql;
page_load赋值
Default2.lcSql = "select * from record where 1=1";
checkbox拼接
//CheckBoxList1
//时间周期
if ((this.txtbegintime.Text.Trim().Length != 0 && this.txtendtime.Text.Trim().Length != 0) && (this.CheckBoxList1.Items[0].Selected))
Default2.lcSql += "and accepttime between '" + this.txtbegintime.Text + "' and '" + this.txtendtime.Text + "' ";
//发送内容
if ((this.txtcontent.Text.Trim().Length != 0) && (this.CheckBoxList1.Items[1].Selected))
Default2.lcSql += " and content like'" + this.txtcontent.Text.Trim() + "%'";
//场所名称position
if ((this.txtplacename.Text.Trim().Length != 0) && (this.CheckBoxList1.Items[2].Selected))
Default2.lcSql += " and position like'" + this.txtplacename.Text.Trim() + "%'";