CheckBoxList多条件取值,sql查询
2014-09-29 13:17
253 查看
protected void searchbtn_Click(object sender, EventArgs e)
{
int num1=this.locality.Items.Count;
int num2 = this.classify.Items.Count;
string str1=null;
string str2= null;
for(int i=0;i<num1;i++)
{
if(this.locality.Items[i].Selected==true)
{
str1 +="'"+locality.Items[i].Value.ToString()+"'";
// Response.Write(this.CheckBoxList1.SelectedItem.Value);
}
}
for (int i = 0; i < num2; i++)
{
if (this.classify.Items[i].Selected == true)
{
str2 += "'" + classify.Items[i].Value.ToString() + "'";
// Response.Write(this.CheckBoxList1.SelectedItem.Value);
}
}
if (str1!=null)
{
str1 = str1.Replace("''", "','");
where = where + " and locusarea in (" + str1 + ")";
}
if (str2 != null)
{
str2 = str2.Replace("''", "','");
where = where + " and SecondaryClassification in (" + str2 + ")";
}
bindhot(where);
}
{
int num1=this.locality.Items.Count;
int num2 = this.classify.Items.Count;
string str1=null;
string str2= null;
for(int i=0;i<num1;i++)
{
if(this.locality.Items[i].Selected==true)
{
str1 +="'"+locality.Items[i].Value.ToString()+"'";
// Response.Write(this.CheckBoxList1.SelectedItem.Value);
}
}
for (int i = 0; i < num2; i++)
{
if (this.classify.Items[i].Selected == true)
{
str2 += "'" + classify.Items[i].Value.ToString() + "'";
// Response.Write(this.CheckBoxList1.SelectedItem.Value);
}
}
if (str1!=null)
{
str1 = str1.Replace("''", "','");
where = where + " and locusarea in (" + str1 + ")";
}
if (str2 != null)
{
str2 = str2.Replace("''", "','");
where = where + " and SecondaryClassification in (" + str2 + ")";
}
bindhot(where);
}
相关文章推荐
- SQL查询返回数据多列,保存在list中时,怎么取值
- Mybatis查询实例,sql中的in在Mybatis中怎么写--以list为查询条件
- Mybatis查询实例,sql中的in在Mybatis中怎么写--以list为查询条件
- checkboxlist复选,用作查询条件
- SQL中以count及sum为条件的查询 推荐
- pl/sql中在where in()子句里怎么使用字符串变量来传递查询条件?
- [导入]SQL 查询语句中交叉条件的应用!
- sqlserver中分组查询,条件过滤,排序,写这个sql,我为自己感到骄傲
- 将SQL查询分组后获得的结果中的某字段按照条件相加
- sql数据的like查询条件方案
- 条件放在表中的SQL查询的解决方案
- 在ASP中使用SQL语句之2:用WHERE子句设置查询条件
- 动态生成SQL查询条件定制表单及语句的脚本
- CheckBoxList取值及勾选上
- 将SQL查询分组后获得的结果中的某字段按照条件相加
- SQL查询用Like搜索条件中的模式匹配
- Sql多条件查询
- SQL查询日期条件则无法返回正常结果
- 多项查询条件组合下的SQL语句生成
- SQL 查询语句中交叉条件的应用!