传值页面后台代码:
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中。 在线等。先谢了!
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中。 在线等。先谢了!
{get;set;}
Page_Load
id=Request.QueryString["eid"]==null?"":Request.QueryString["eid"].ToString();
{
get {return ViewState["id"].ToString();}
set {ViewState["id"]=value;}
}
string id=Request.QueryString["eid"].ToString();
string sql="select * from 表 where typeID = "+id;
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 24: {
行 25:
行 26: string lnk = Request.QueryString["eid"].ToString();行 27: SqlConnection sqlcon = new SqlConnection();
行 28: SqlDataAdapter sda;
string lnk = "products/spot.aspx? eid=" + typeID;?和eid=...之间应该你有空格了!应该是:
string lnk = "products/spot.aspx?eid=" + typeID;
我传值的页面没问题(包括你说的空格都有空),是收页面代码有问题:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例
在浏览器的地址栏看看是否有
...../products/spot.aspx?eid=x
x是指某个数!
http://localhost:4687/ccetsite/products/spot.aspx?%20eid=NCP1230D65R2G
Response.Redirect(lnk);
请问在spot.aspx的后台要怎么接收这个值,并用这个来查询数据库