如何在前一页把一个字符串 如str传给下一页面 的SqlDataSource控件,做为SelectCommand查询的条件:
  SelectCommand="select * from table where str" 这里的语法提示有问题,str在这里该如何表示,谢谢了

解决方案 »

  1.   

    当前页:
    Response.Redirect(xxx.xxx.xxx?str=value)
    下一页
    str = Request.QueryString["str"]
    SelectCommand = "select * from table where " + str
      

  2.   

    假如你下一页的地址是www.baidu.com那么
    href="www.baidu.com?str="+str;下一页:在Page_Load方法中写
    string str = Request.Params["id"];
    SqlDataSource对象.SelectCommand="select * from table where str='"+str+"'";
      

  3.   

     按照bingen68的的做法出现
    错误验证 (ASP.Net): 此属性名称必须后跟一个等号(=)和一个值。如果用引号将该值括起来,则必须成对使用引号。
      

  4.   

    1楼的方法可以实现也可以先把值保存到session中
      

  5.   

    我好象是保存到session里。一般做的就是把用户登陆后.在第2个界面欢迎他...比较简单的!
      

  6.   

    传值是Response.Redirect(xxx.aspx?参数名=值) 然后跳转到页面用Request.QueryString["参数名"]得到前面传来的值然后自己写进sql语句去
      

  7.   

    给你个例子:
    string num="123";
    Response.Redirect("WebForm2.aspx?str="+num);WebForm2.aspx页面接受:
    string thenum=Request.QueryString["str"].ToString();
      

  8.   

    你可以这样写:
    SelectCommand="select   *   from   table   where "+ str
      

  9.   

    可以创建一个全局静态变量,只有这样,这个变量可以保留住你给的值,你可以试下
    public static string str;
    顺序我忘了,不过程序会给提示,然后给值
    str="name='a'"
    name 是字段, a 是值
    SelectCommand="select   *   from   table   where" + str
      

  10.   

    要注意str里内容的格式,数字可以不要引号,字符则需要
    SelectCommand="select       *       from       table       where ‘"   +   str + “’”
      

  11.   

    SelectCommand="select               *               from               table               where   ‘"       +       str   +   “’” 错了,收回,可以参考13楼的,呵呵
      

  12.   

    str   =   Request.QueryString["str"] 
    SelectCommand   =   "select   *   from   table   where   "   +   str 另外考虑中文传值的时候,
    参数要encode一下。
    接的时候显示要decode一下,。
    Server.Encode(str);
    Server.Decode(str);
      

  13.   

    SelectCommand="select  *   from  table   where  ‘"  + str + “’”  这样操作是可以了,谢谢liuyang1981 
     
    如果我要加通配符的话,该如何来加呢? 用like和通配符来查询的时候
      

  14.   

    终于可以了, strWhere += "字段1 like '%" + ghmc + "%' and ";谢谢大家的帮助! 结了,呵呵