当前位置: 代码迷 >> ASP.NET >> 搜索分页时使用Cookies保存搜索条件的有关问题
  详细解决方案

搜索分页时使用Cookies保存搜索条件的有关问题

热度:656   发布时间:2013-02-25 00:00:00.0
搜索分页时使用Cookies保存搜索条件的问题
//获得搜索参数开始
                string   SearchTypes   =   DDL_SearchTypes.Text;
                string   Key   =   tb_Key.Text.ToString();
                string   str_c   =   " ";
                if   (SearchTypes   !=   " "   &&   Key   !=   " ")
                {
                        intPageNo   =   1;
                        str_c   =   "And   "   +   SearchTypes   +   "   Like   ' "   +   '% '   +   Key   +   '% '   +   " ' ";
                        Response.Cookies[ "strc "].Value   =str_c;
                }
                string   str_Condition   =   Request.Cookies[ "strc "].Value;
                Response.Write(str_Condition);
                //获得搜索参数结束


                //查询条件,不需where "
                workParm   =   mySqlCommand.Parameters.Add( "@strCondition ",   SqlDbType.VarChar,   500);
                mySqlCommand.Parameters[ "@strCondition "].Value   =   str_Condition;


问题如下:
非要点两次搜索才能搜索到正确结果

我换关键字的时候,我用Response.Write(str_Condition);输出时,第一次还是输出了老Cookies的内容,非要第二次点搜索才会正确显示,是怎么一回事,请高手指点

------解决方案--------------------------------------------------------
自己写一个绑定控件,内置分页,搜索的参数可传可接收不就可以了吗
  相关解决方案