protected void Page_Load(object sender, EventArgs e) { if (Session["UserId"] != null) { int uid = int.Parse(Session["UserId"].ToString()); lblTotalPrice.Text = TotalPrice(uid).ToString(); //判断该用户的购物车是否为空 if (!cartService.IsCartItemEmptyByUserId(uid)) { BtnClearAll.OnClientClick = "return confirm('确定要清空购物车吗?');"; gvShopCart.DataSourceID = "LinqCartItem"; LinqCartItem.Where = "UserId == " + uid; } else { lblPageCountMsg.Text = ""; lblNullMsg.Text = "当前购物车空空如也~~~快去添加点东西吧!"; // gvShopCart.Visible = false; lblTotalPrice.Text = "0.00"; BtnAddToOrder.Enabled = false; BtnClearAll.Enabled = false; } } else { Response.Redirect("Login.aspx"); } }