很简单的问题,但是一下子要用居然想不起来了,汗一个,不得不上网狂找资料。
最后终于解决了,把代码贴一下,以免又忘记了。唉,年纪不饶人呐。
protected void gridData_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (this.ShoppingCartInfoObj != null)
{
if (e.CommandName == "delete")
{
Button btn = e.CommandSource as Button;
System.Web.UI.Control c = btn.NamingContainer;
GridViewRow row = c as GridViewRow;
Label lblGuid = row.FindControl("lblGuid") as Label;
Guid cartItemGuid = ValidationHelper.GetGuid(lblGuid.Text, Guid.Empty);
ShoppingCartItemInfo cartItem = this.ShoppingCartInfoObj.GetShoppingCartItemInfo(cartItemGuid);
if (cartItem != null)
{
// Remove product and its product option from list
this.ShoppingCartInfoObj.RemoveShoppingCartItem(cartItemGuid);
// Delete product from database
ShoppingCartItemInfoProvider.DeleteShoppingCartItem(cartItem);
}
}
}