private void LoadData()
        {
            Gallery_Collection collection_obj = gallery_collection_obj.GetDetails(_idx);

            txtTitle.Text           = collection_obj.Title;
            ltrFileName.Text        = collection_obj.IconFile;
            txtTags.Text            = collection_obj.Tags;
            txtDescription.Text     = collection_obj.Description;
            rdlStatus.SelectedValue = collection_obj.Status.ToString();
            ShowTreeNodes_Topics(collection_obj.TopicId.ToString());

            string file_name = string.Empty;

            if (collection_obj.IconFile != string.Empty)
            {
                Uri    requestUri = Context.Request.Url;
                string baseUrl    = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);
                imgPhoto.ImageUrl = baseUrl + "/" + upload_gallery_collection_image_dir + "/" + collection_obj.IconFile;
            }

            ViewState["ListOrder"]     = collection_obj.ListOrder;
            ViewState["IPLog"]         = collection_obj.IPLog;
            ViewState["CreatedOnDate"] = collection_obj.CreatedOnDate;
            ViewState["UserLog"]       = collection_obj.UserLog;
        }
        public bool UpdateData(int Idx, int TopicId, string Title, string IconFile, string Description, int ListOrder, string Tags, string Url,
                               string UserLog, string UserLastUpdate, DateTime CreatedOnDate, string IPLog, string Status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.Connection.Open();
                Gallery_Collection collection_obj = new Gallery_Collection();
                collection_obj.CollectionId = Idx;
                collection_obj.TopicId = TopicId;
                collection_obj.Title = Title;
                collection_obj.IconFile = IconFile;
                collection_obj.Description = Description;
                collection_obj.ListOrder = ListOrder;
                collection_obj.UserLog = Guid.Parse(UserLog);
                collection_obj.UserLastUpdate = Guid.Parse(UserLastUpdate);
                collection_obj.CreatedOnDate = CreatedOnDate;
                collection_obj.LastModifieddDate = DateTime.Now;
                collection_obj.Status = Convert.ToChar(Status);
                collection_obj.Tags = Tags;
                collection_obj.Url = Url;
                collection_obj.IPLog = IPLog;
                collection_obj.IPLastUpdate = IP;

                ChangeSet changeSet = null;
                int changeCount = 0;
                DbTransaction trans = context.Connection.BeginTransaction();
                try
                {
                    context.Transaction = trans;
                    context.Gallery_Collections.Attach(collection_obj);
                    context.Refresh(RefreshMode.KeepCurrentValues, collection_obj);
                    changeSet = context.GetChangeSet();
                    changeCount = changeSet.Updates.Count;
                    context.SubmitChanges();

                    trans.Commit();
                   
                }
                catch (Exception ex)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    throw ex;
                }
                finally
                {
                    if (context.Connection != null && context.Connection.State == System.Data.ConnectionState.Open)
                    {
                        context.Connection.Close();
                    }
                }

                if (changeCount > 0) { return true; }
                else { return false; }
            }        
        }
        public bool InsertData(int TopicId, string Title, string IconFile, string Description, string Tags, string Url,
	                           string UserLog, string Status)
        {
            using(GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                System.Nullable<Int32> ListOrder = (int?)context.Gallery_Collections.Max(x => (int?)x.CollectionId) ?? 0;
                Gallery_Collection collection = new Gallery_Collection();
                collection.TopicId = TopicId;
                collection.Title = Title;
                collection.IconFile = IconFile;
                collection.Description = Description;
                collection.ListOrder = ListOrder + 1;
                collection.UserLog = Guid.Parse(UserLog);
                collection.UserLastUpdate = Guid.Parse(UserLog);
                collection.CreatedOnDate = System.DateTime.Now;
                collection.LastModifieddDate = System.DateTime.Now;
                collection.Status = Convert.ToChar(Status);
                collection.Tags = Tags;
                collection.Url = Url;
                collection.IPLog = IP;
                collection.IPLastUpdate = IP;

            
                context.Gallery_Collections.InsertOnSubmit(collection);
                context.SubmitChanges();
                int newCollectionId = collection.CollectionId;
                if (newCollectionId > 0) { return true; }
                else { return false; }
            }
        }