Exemple #1
0
        protected void UpsellProductGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int upsellProductId = (int)e.Keys[0];

            SetLink(upsellProductId, false);
            //CHECK THE SEARCH RESULTS GRID TO SEE IF THIS ITEMS APPEARS
            int tempIndex = 0;

            foreach (DataKey key in UpsellProductGrid.DataKeys)
            {
                int tempId = (int)key.Value;
                if (upsellProductId == tempId)
                {
                    //CHANGE THE REMOVE BUTTON TO ADD FOR THIS ROW
                    ImageButton removeButton = UpsellProductGrid.Rows[tempIndex].FindControl("RemoveButton") as ImageButton;
                    if (removeButton != null)
                    {
                        removeButton.Visible = false;
                    }
                    ImageButton attachButton = UpsellProductGrid.Rows[tempIndex].FindControl("AttachButton") as ImageButton;
                    if (attachButton != null)
                    {
                        attachButton.Visible = true;
                    }
                    break;
                }
                tempIndex++;
            }
            UpsellProductGrid.DataBind();
            e.Cancel = true;
        }
Exemple #2
0
 protected void UpsellProductGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "MoveUp")
     {
         IList <UpsellProduct> UpsellProducts = _Product.UpsellProducts;
         int itemIndex = AlwaysConvert.ToInt(e.CommandArgument);
         if ((itemIndex < 1) || (itemIndex > UpsellProducts.Count - 1))
         {
             return;
         }
         UpsellProduct selectedItem = UpsellProducts[itemIndex];
         UpsellProduct swapItem     = UpsellProducts[itemIndex - 1];
         UpsellProducts.RemoveAt(itemIndex - 1);
         UpsellProducts.Insert(itemIndex, swapItem);
         for (int i = 0; i < UpsellProducts.Count; i++)
         {
             UpsellProducts[i].OrderBy = (short)i;
         }
         UpsellProducts.Save();
         UpsellProductGrid.DataBind();
     }
     else if (e.CommandName == "MoveDown")
     {
         IList <UpsellProduct> UpsellProducts = _Product.UpsellProducts;
         int itemIndex = AlwaysConvert.ToInt(e.CommandArgument);
         if ((itemIndex > UpsellProducts.Count - 2) || (itemIndex < 0))
         {
             return;
         }
         UpsellProduct selectedItem = UpsellProducts[itemIndex];
         UpsellProduct swapItem     = UpsellProducts[itemIndex + 1];
         UpsellProducts.RemoveAt(itemIndex + 1);
         UpsellProducts.Insert(itemIndex, swapItem);
         for (int i = 0; i < UpsellProducts.Count; i++)
         {
             UpsellProducts[i].OrderBy = (short)i;
         }
         UpsellProducts.Save();
         UpsellProductGrid.DataBind();
     }
 }