/// <summary>
    /// Handles the ItemDataBound event of the repItems control.
    /// </summary>
    protected void repItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            object dataItem = e.Item.DataItem;
            if (dataItem.GetType() == typeof(DataRowView))
            {
                // Get data row
                DataRow dr = ((DataRowView)dataItem).Row;
                if (dr["ObjectType"].ToString() == "webpartcategory")
                {
                    string currentCategory = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(Convert.ToString(dr["DisplayName"]), prefferedUICultureCode));
                    int    currentLevel    = ValidationHelper.GetInteger(dr["ObjectLevel"], -1);

                    // Ignore item template defined in markup
                    e.Item.Controls.Clear();

                    // Render only top level categories
                    if (currentLevel == 1)
                    {
                        Literal ltl = new Literal();
                        ltl.Text = @"<div class=""WPTCat""><h4>" + currentCategory + "</h4></div>";
                        e.Item.Controls.Add(ltl);
                    }
                }
                else
                {
                    // Setup the web part item
                    Panel wptFlatItem = ((Panel)e.Item.FindControl("i"));
                    if (wptFlatItem != null)
                    {
                        string toolTip = ResHelper.LocalizeString(Convert.ToString(dr["WebPartDescription"]), prefferedUICultureCode);
                        toolTip             = String.IsNullOrEmpty(toolTip) ? GetString("webparttoolbar.nodescription") : toolTip;
                        wptFlatItem.ToolTip = "<div class='WPTTH'>" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(Convert.ToString(dr["DisplayName"]), prefferedUICultureCode)) + "</div><div class='WPTTC'>" + HTMLHelper.HTMLEncode(toolTip) + "</div>";

                        // Set the web part id
                        wptFlatItem.Attributes.Add("data-webpartid", Convert.ToString(dr["ObjectID"]));

                        // Ensure that when start dragging then a copy of the original web part item will be created
                        wptFlatItem.Attributes.Add("data-dragkeepcopy", "1");
                        wptFlatItem.Attributes.Add("onmouseover", "wptToggle(this, true);");
                        wptFlatItem.Attributes.Add("onmouseout", "wptToggle(this, false);");

                        // Skip the insert properties dialog when the web part allows this behavior
                        if (ValidationHelper.GetBoolean(dr["WebPartSkipInsertProperties"], false))
                        {
                            wptFlatItem.Attributes.Add("data-skipdialog", "1");
                        }
                    }

                    // Insert parent category names into HTML comment to be able filter web parts by category name
                    Literal ltlComm = ((Literal)e.Item.FindControl("ltlCategorytComment"));
                    if (ltlComm != null)
                    {
                        ltlComm.Text = "<!-- " + HTMLHelper.EncodeForHtmlComment(GetParentCategories(dr)) + " -->";
                    }

                    // Build the web part image html
                    Literal ltrImage = ((Literal)e.Item.FindControl("ltrImage"));
                    if (ltrImage != null)
                    {
                        imageHTML = PortalHelper.GetIconHtml(
                            thumbnailGuid: ValidationHelper.GetGuid(dr["ThumbnailGUID"], Guid.Empty),
                            iconClass: ValidationHelper.GetString(dr["IconClass"], PortalHelper.DefaultWebPartIconClass));

                        ltrImage.Text = imageHTML;
                    }
                }
            }
        }
    }