//获得搜索参数开始
        string SearchTypes = DDL_SearchTypes.Text;
        string Key = tb_Key.Text.ToString();
        if (SearchTypes != "" && Key != "")
        {
            intPageNo = 1;
            Response.Cookies["strc"].Value = "And " + SearchTypes + " Like '" + '%' + Key + '%' + "'";            
            //Session["strc"] = "And " + SearchTypes + " Like '" + '%' + Key + '%' + "'";                    }
        //string str_Condition = Session["strc"].ToString();
        string str_Condition = Request.Cookies["strc"].Value.ToString();
        //Response.Write(str_c);
        Response.Write(str_Condition);
        //获得搜索参数结束
每次换关键字搜索要点两次,str_Condition的值才会变,Cookies更新不及时,第一次清寒是显示的老的,第二次才显示新的.

解决方案 »

  1.   

    是的,这样解决
    string x = "And " + SearchTypes + " Like '" + '%' + Key + '%' + "'";    
    Response.Cookies["strc"].Value = x;
    string str_Condition = x;
      

  2.   

    这样早试过,没用,不能传参,只有用Cookies或Session才可以,Session我试过,可以用,一点问题都没有,但是Session比较占服务器的资源所以我不用,这里要用Cookies,但是非要点两次,更新不及时
      

  3.   

    但是Session比较占服务器的资源所以我不用