protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "look1")
{
Int32 id = Int32.Parse(DataList1.DataKeys[e.Item.ItemIndex].ToString());//获得当前商品编号
Response.Write("<script language='javascript'>window.open('goodslook.aspx?goodid=" + id + "');document.location=document.location;</script>");
//在新窗口中弹出商品详细信息页面
}
if (!IsPostBack)
{ SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["connstr"]);
conn.Open();
Int32 id = Convert.ToInt32(Request.QueryString["goodsid"]);
string sql = "select * from dbo.Goods where GoodsID=" + id;
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds); this.Label1.Text = ds.Tables[0].Rows[0][3].ToString();
结果id就变0了..报错了
{
if (e.CommandName == "look1")
{
Int32 id = Int32.Parse(DataList1.DataKeys[e.Item.ItemIndex].ToString());//获得当前商品编号
Response.Write("<script language='javascript'>window.open('goodslook.aspx?goodid=" + id + "');document.location=document.location;</script>");
//在新窗口中弹出商品详细信息页面
}
if (!IsPostBack)
{ SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["connstr"]);
conn.Open();
Int32 id = Convert.ToInt32(Request.QueryString["goodsid"]);
string sql = "select * from dbo.Goods where GoodsID=" + id;
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds); this.Label1.Text = ds.Tables[0].Rows[0][3].ToString();
结果id就变0了..报错了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货