我的1.aspx页面中有个dropdownlist控件,点击一个BUTTON按纽转到一个数据绑定页面2.aspx。因为dropdownlist中选中的值如果不一样,那么2.aspx中绑定的数据就不一样,请问怎么在页面2.aspx中能调用的1.aspx中dropdownlist的选定值作为页面2.aspx中绑定数据的判断条件?

解决方案 »

  1.   

    转到另一个页面2.aspx 的时候顺便将dropdownlist的值传过去。
    如下:
    Response.Redirect("2.aspx?ID="+dropdownlist.selectItem.Text);
    然后在2.aspx上:
    string s=Request.QueryString["ID"].ToString();
    s就是第一个页面所选的值。
      

  2.   

    Response.Redirect("2.aspx?ID=" + HttpUtility.UrlEncode( this.DropDownList.SelectedValue.ToString()), true);2.ASPX接:
     Request.QueryString["ID"]
      

  3.   

    url传参
    session传参或者Server.Redirect()可以实现form提交,但这样不好,提交了没用的数据
      

  4.   

    按钮事件中可以把dropdownlist选定的值传过去啊
    然后在2.aspx中定义一个属性来取这个传过来的值。绑定时就取传递过来的值就好啊传值可以在地址中传啊
    http://2.aspx?pass = value (可以在js中定义)
      

  5.   

    但我用的是
    Response.Write("<script language=\"javascript\">window.open(\"2.aspx?stime="+statetime+"\",\"excel\");</script>");
    这样还能把值传过来吗?
      

  6.   

    但我用的是 
    Response.Write(" <script   language=\"javascript\"> window.open(\"2.aspx?stime="+statetime+"\",\"excel\"); </script> "); 
    这样还能把值传过来吗?
    --------------2.ASPX接: 
      Request.QueryString["stime"]
      

  7.   

    我一下要传递两个怎么办呢?
    Response.Write("   <script       language=\"javascript\">   window.open(\"2.aspx?stime="+statetime+"\",\"excel\");   </script>   ");   这个把stime传过去了,但还要把dropdownlist的值也传过去啊,该怎么写啊?
      

  8.   

    2.aspx?后面能连续接两个参数的传值吗?
      

  9.   

    Response.Write("   <script       language=\"javascript\">   window.open(\"2.aspx?stime="+statetime+"&ddl="+dropdownlist.selectvalue+"\",\"excel\");   </script>   ");   
      

  10.   

    Response.Redirect("2.aspx?ID="+dropdownlist.selectItem.Text); 
    string   s=Request.QueryString["ID"].ToString(); 
      

  11.   

    一般做法
    1.aspx:
    Response.Redirect("2.aspx?ID="+dropdownlist.selectItem.Text);
    2.aspx接收值.   
    string       s=Request.QueryString["ID"].ToString();   
    如果要处理多个参数,在参数之间使用&地址符号连接
    2.aspx?ID=m&id=n
    建议:
    1.传值不要使用服务器的SESSION什么的这样会很消耗服务器资源
    2.在接收的页面代码要对参数进行防SQL注入处理
      

  12.   

    传两个的话就在第一个后面加上字符:&,你写的方法取得时候可以用Request.QueryString来取。
      

  13.   

    值传过来了,谢谢大家,但是还有个小问题,执行完string s=Request.QueryString["ID"].ToString(); 后
    我用s的值来判断如下
    if(s=="All")
    sql="select.....";
    else
    sql="select....where type=s";  
    但报错说:列名s无效,是怎么回事?
      

  14.   

    值传过来了,谢谢大家,但是还有个小问题,执行完string   s=Request.QueryString["ID"].ToString();   后 
    我用s的值来判断如下 
    if(s=="All") 
    sql="select....."; 
    else 
    sql="select....where   type=s";     
    但报错说:列名s无效,是怎么回事? 
    传过来的值不能这么用么?