protected void DeleteButton_Click(object sender, EventArgs e)
        {
            List <String> messages = new List <string>();

            // Looping through all the rows in the GridView
            foreach (GridViewRow row in ImageFilesGrid.Rows)
            {
                CheckBox checkbox = (CheckBox)row.FindControl("DeleteCheckbox");
                if ((checkbox != null) && (checkbox.Checked))
                {
                    String fileName = ImageFilesGrid.DataKeys[row.RowIndex].Value.ToString();
                    if (!String.IsNullOrEmpty(fileName))
                    {
                        if (!DeleteFile(fileName))
                        {
                            // DELETE FAILS, LOG FILE NAME FOR ERROR MESSAGE
                            messages.Add(fileName);
                        }
                    }
                }
            }
            ImageFilesGrid.DataBind();
            MessagePanel.Visible = (messages.Count > 0);
            if (messages.Count > 0)
            {
                PopulateMessages(messages);
            }
        }
        protected void CatalogItemTypeList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedIndex = AlwaysConvert.ToInt(CatalogItemTypeList.SelectedValue);

            //DEFAULT VISIBILITY
            CatalogItemsPanel.Visible = (selectedIndex != 5);
            ImagesPanel.Visible       = (selectedIndex == 5);

            switch (selectedIndex)
            {
            case 1: CGrid.DataSourceID = "CategoryDs"; break;

            case 2: CGrid.DataSourceID = "ProductsDs"; break;

            case 4: CGrid.DataSourceID = "LinksDs"; break;

            case 5:
                // DISPLAY IMAGES GRID AND DELETE BUTTON
                ImagesPanel.Visible = true;
                ImageFilesGrid.DataBind();

                // HIDE THE CATALOG ITEMS PANEL
                CatalogItemsPanel.Visible = false;
                break;

            default: CGrid.DataSourceID = "ProductsDs"; break;
            }
        }
 protected void ImageFilesGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     ImageFilesGrid.PageIndex = e.NewPageIndex;
     ImageFilesGrid.DataBind();
 }