传值页面代码: 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);
}接值页面代码:public partial class products_spot : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListBind();
string id = "";
if (Request.QueryString["eid"] != null)
{
id = Request.QueryString["eid"].ToString();
SqlConnection sqlcon = new SqlConnection();
SqlDataAdapter sda;
DataSet ds = new DataSet();
string sqlconstr = "Data Source=***;Initial Catalog=***;User ID=sa;Password=***";
sqlcon.ConnectionString = sqlconstr;
string sqlcmd = "SELECT spot.* FROM spot WHERE (typeID like " + id + ")";
using (sda = new SqlDataAdapter(sqlcmd, sqlcon))
{
try
{
sda.Fill(ds, "product");
Session["ds"] = ds;
}
catch (TimeoutException ex)
{
Response.Write(ex.Message.ToString());
}
}
gv1.DataSource = ds.Tables["product"].DefaultView;
gv1.DataBind();
DL2.DataSource = ds.Tables["product"].DefaultView;
DL2.DataBind();
DL3.DataSource = ds.Tables["product"].DefaultView;
DL3.DataBind();
}
else { return; }
}
}......问题是:gv1、DL2、DL3没有数据显示。click后地址网有看到要传的值(...eid=typeID).而在本页内linkbutton传的值可以查询到数据(gv1、DL2、DL3有正确的数据显示出)。请行家帮忙查查原因,先谢了。
{
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);
}接值页面代码:public partial class products_spot : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListBind();
string id = "";
if (Request.QueryString["eid"] != null)
{
id = Request.QueryString["eid"].ToString();
SqlConnection sqlcon = new SqlConnection();
SqlDataAdapter sda;
DataSet ds = new DataSet();
string sqlconstr = "Data Source=***;Initial Catalog=***;User ID=sa;Password=***";
sqlcon.ConnectionString = sqlconstr;
string sqlcmd = "SELECT spot.* FROM spot WHERE (typeID like " + id + ")";
using (sda = new SqlDataAdapter(sqlcmd, sqlcon))
{
try
{
sda.Fill(ds, "product");
Session["ds"] = ds;
}
catch (TimeoutException ex)
{
Response.Write(ex.Message.ToString());
}
}
gv1.DataSource = ds.Tables["product"].DefaultView;
gv1.DataBind();
DL2.DataSource = ds.Tables["product"].DefaultView;
DL2.DataBind();
DL3.DataSource = ds.Tables["product"].DefaultView;
DL3.DataBind();
}
else { return; }
}
}......问题是:gv1、DL2、DL3没有数据显示。click后地址网有看到要传的值(...eid=typeID).而在本页内linkbutton传的值可以查询到数据(gv1、DL2、DL3有正确的数据显示出)。请行家帮忙查查原因,先谢了。
string lnk = "products/spot.aspx? eid=" + typeID;
====================
?和eid间有空格!
应该是没有空格滴!
列名 'NCP1014ST65T3G' 无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 列名 'NCP1014ST65T3G' 无效。源错误:
行 39: try
行 40: {
行 41: sda.Fill(ds, "spot");
行 42: Session["ds"] = ds;
行 43: }