string whereClause = "";
if(DropDown1.SelectItem.Value = -1) {
  whereClause = ""
}
else if(DropDown1.SelectItem.Value = 1) {
  whereClause = "where 分类='分类1'"
}
else if(...cmdText.CommandText = "select * from theTable " + whereClause;

解决方案 »

  1.   

    拼你的sql语句的时候去掉啊
    string varWhere = ""
    if(this.ddl....SelectedValue != -1)
    {
        varWhere = " pclass_id = " + this.ddl......SelectedValue;
    }string sql = "select * from xxx" + varWhere;....
      

  2.   

    private void dgDataBind(string condition,string SortExpression)
    {
    string strSql="";
    strSql="select wynumber,wytitle,wysenddate,wykeyword,wysavedate from wypolicy where 1<>2 ";

    if(condition!="")
    {
    strSql += condition + " order by wysavedate desc";
    }
    else
    {
    strSql+=" order by wysavedate desc";
    } string varWhere = "";
    if(this.wyclass.SelectedIndex != -1)
    {
    varWhere = " Value = " + this.wyclass.SelectedValue;
    } string sql = "select * from wypolicy" + varWhere;
    //Response.Write(strSql);

    DataSet ds = cc.GetDataSet(strSql,myCn);
    dgShow.DataSource=ds;
    dgShow.DataBind(); PageUpDown1.DataSource  = ds;
    PageUpDown1.Select();
    }
    不对啊
    还是不行啊
    请指出我的错误