传值页面后台代码:
  protected void lkb_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        string typeID = lb.CommandArgument.ToString().Trim();
        int Row = ((GridViewRow)lb.Parent.Parent).RowIndex;
        string user = GV1.Rows[Row].Cells[0].Text.ToString().Trim();
        string lnk = "products/spot.aspx? eid=" + typeID;
        Response.Redirect(lnk);    请问在spot.aspx里怎么接收,并把传过来的值做为SQL查询语句WHERE的值(typeID="+ 值  +"),来查询数据库。然后将值绑定到Gridview中。    在线等。先谢了!

解决方案 »

  1.   

    public string id
    {get;set;}
    Page_Load
     id=Request.QueryString["eid"]==null?"":Request.QueryString["eid"].ToString();
      

  2.   

    public string id
    {
    get {return ViewState["id"].ToString();}
    set {ViewState["id"]=value;}
    }
      

  3.   

    能具体点吗?在SQL查询中怎么引用传递过来的值
      

  4.   

    页面接受:
    string id=Request.QueryString["eid"].ToString();
    string sql="select * from 表 where typeID = "+id;
      

  5.   

    未将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 24:         {
    行 25:             
    行 26:             string lnk = Request.QueryString["eid"].ToString();行 27:             SqlConnection sqlcon = new SqlConnection();
    行 28:             SqlDataAdapter sda;
     
      

  6.   

    仔细看你的传递参数的代码!!
    string lnk = "products/spot.aspx? eid=" + typeID;?和eid=...之间应该你有空格了!应该是:
    string lnk = "products/spot.aspx?eid=" + typeID;
      

  7.   


    我传值的页面没问题(包括你说的空格都有空),是收页面代码有问题:
       异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例
      

  8.   

    先确定一下是否传递了数据!!
    在浏览器的地址栏看看是否有
    ...../products/spot.aspx?eid=x
    x是指某个数!
      

  9.   

    NCP1230D65R2G这就是要传递的值。
    http://localhost:4687/ccetsite/products/spot.aspx?%20eid=NCP1230D65R2G
      

  10.   

    string lnk = "products/spot.aspx?eid="+typeID;
    Response.Redirect(lnk);
      

  11.   


    请问在spot.aspx的后台要怎么接收这个值,并用这个来查询数据库