您的位置:首页 > 数据库

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);

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: