private void PopulateDataGrid()
        {
            this.dvDataContent.Visible    = false;
            this.dvEmptyContent.Visible   = false;
            this.dvNoSearchResult.Visible = false;

            string searchText = this.txtSearch.Text.ToLower().Trim();

            AccessoryColorBO        objPatternAccessoryColor = new AccessoryColorBO();
            List <AccessoryColorBO> lstPatternAccessoryColor = new List <AccessoryColorBO>();

            if (txtSearch.Text != string.Empty && txtSearch.Text != "search")
            {
                lstPatternAccessoryColor = (from ac in objPatternAccessoryColor.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList()
                                            where ac.Name.ToLower().Contains(searchText) ||
                                            ac.Code.ToLower().Contains(searchText) ||
                                            ac.ColorValue.ToLower().Contains(searchText)
                                            select ac).ToList();
            }
            else
            {
                lstPatternAccessoryColor = objPatternAccessoryColor.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList();
            }

            if (lstPatternAccessoryColor.Count > 0)
            {
                this.RadGridColor.AllowPaging = (lstPatternAccessoryColor.Count > this.RadGridColor.PageSize);
                this.RadGridColor.DataSource  = lstPatternAccessoryColor;
                this.RadGridColor.DataBind();
                Session["AccessoryColorDetails"] = lstPatternAccessoryColor;

                this.dvDataContent.Visible = true;
            }
            else if ((searchText != string.Empty && searchText != "search"))
            {
                this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty);

                this.dvDataContent.Visible    = true;
                this.dvNoSearchResult.Visible = true;
            }
            else
            {
                this.dvEmptyContent.Visible       = true;
                this.btnAddAccessoryColor.Visible = false;
            }

            this.RadGridColor.Visible = (lstPatternAccessoryColor.Count > 0);
        }
        private void ProcessForm(int accessorycolorsId, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    AccessoryColorBO objAccessoryColor = new AccessoryColorBO(this.ObjContext);
                    if (accessorycolorsId > 0)
                    {
                        objAccessoryColor.ID = accessorycolorsId;
                        objAccessoryColor.GetObject();
                    }

                    if (isDelete)
                    {
                        objAccessoryColor.Delete();
                    }
                    else
                    {
                        objAccessoryColor.Name       = this.txtColorName.Text;
                        objAccessoryColor.Code       = this.txtCode.Text;
                        objAccessoryColor.ColorValue = this.hdnColorValue.Value.ToString();

                        if (accessorycolorsId == 0)
                        {
                            objAccessoryColor.Add();
                        }
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while saving Accessory color ViewAccessoryColor page", ex);
            }
        }
        protected void RadGridColor_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;

                if (item.ItemIndex > -1 && item.DataItem is AccessoryColorBO)
                {
                    AccessoryColorBO objPatternAccessoryColor = (AccessoryColorBO)item.DataItem;

                    HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit");
                    linkEdit.Attributes.Add("qid", objPatternAccessoryColor.ID.ToString());
                    linkEdit.Attributes.Add("colorvalue", objPatternAccessoryColor.ColorValue.ToString());

                    HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete");
                    linkDelete.Attributes.Add("qid", objPatternAccessoryColor.ID.ToString());
                    linkDelete.Visible = (objPatternAccessoryColor.VisualLayoutAccessorysWhereThisIsAccessoryColor.Count == 0);

                    HtmlGenericControl dvAccessoryColor = (HtmlGenericControl)item.FindControl("dvAccessoryColor");
                    dvAccessoryColor.Attributes.Add("style", "background-color: " + objPatternAccessoryColor.ColorValue.ToString());
                }
            }
        }