System...不包含CommandName的定义,且找不到可接受类型为System.EventArgs的第一个参数的扩展方法
在ImageButton里面设置了CommandName,但是在cs里面调用时候e.CommandName就出现错误。说System.Web.UI.Imageclicke...
在ImageButton里面设置了CommandName,但是在cs里面调用时候e.CommandName就出现错误。说System.Web.UI.Imageclickeventargs不包含CommandName的定义,且找不到可接受类型为System.EventArgs的第一个参数的扩展方法
源代码:
<asp:ImageButton ID="Button1" runat="server" ImageUrl="~/image/buy.bmp" OnClick="btn_goOn_Click" CommandName="gm" />
cs代码:
protected void btn_goOn_Click(object sender, ImageClickEventArgs e)
{
string ID = Request.QueryString["ID"].ToString();
if (e.CommandName == "gm")
{
string cmd = "select * from sale where ID=@ID";
sdr = AccessHelper.ExecuteReader(con, cmd, new OleDbParameter("@ID", ID));
if (sdr.Read())
{
if (Session["bus"] == null)
{
gw.ID = sdr["ID"].ToString();
gw.CommodityName = sdr["CommodityName"].ToString();
gw.Num = 1;
gw.Price = float.Parse(sdr["Price"].ToString());
emp = new Hashtable();
emp.Add(ID, gw);
Session["bus"] = emp;
}
else
{
if (pd(ID))
{
Hashtable emp1 = (Hashtable)Session["bus"];
gowuche g = (gowuche)emp1[ID];
g.Num += 1;
emp1.Remove(ID);
emp1.Add(ID, g);
Session["bus"] = emp1;
}
else
{
gw.ID = sdr["ID"].ToString();
gw.CommodityName = sdr["Name"].ToString();
gw.Num = 1;
gw.Price = float.Parse(sdr["SalePrice"].ToString());
Hashtable emp2 = (Hashtable)Session["bus"];
emp2.Add(ID, gw);
Session["bus"] = emp2;
}
}
}
}
} 展开
源代码:
<asp:ImageButton ID="Button1" runat="server" ImageUrl="~/image/buy.bmp" OnClick="btn_goOn_Click" CommandName="gm" />
cs代码:
protected void btn_goOn_Click(object sender, ImageClickEventArgs e)
{
string ID = Request.QueryString["ID"].ToString();
if (e.CommandName == "gm")
{
string cmd = "select * from sale where ID=@ID";
sdr = AccessHelper.ExecuteReader(con, cmd, new OleDbParameter("@ID", ID));
if (sdr.Read())
{
if (Session["bus"] == null)
{
gw.ID = sdr["ID"].ToString();
gw.CommodityName = sdr["CommodityName"].ToString();
gw.Num = 1;
gw.Price = float.Parse(sdr["Price"].ToString());
emp = new Hashtable();
emp.Add(ID, gw);
Session["bus"] = emp;
}
else
{
if (pd(ID))
{
Hashtable emp1 = (Hashtable)Session["bus"];
gowuche g = (gowuche)emp1[ID];
g.Num += 1;
emp1.Remove(ID);
emp1.Add(ID, g);
Session["bus"] = emp1;
}
else
{
gw.ID = sdr["ID"].ToString();
gw.CommodityName = sdr["Name"].ToString();
gw.Num = 1;
gw.Price = float.Parse(sdr["SalePrice"].ToString());
Hashtable emp2 = (Hashtable)Session["bus"];
emp2.Add(ID, gw);
Session["bus"] = emp2;
}
}
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询