private void CreateTreeData()
        {
            try
            {
                SelectedNodes = (List <string>)Session["SelectedNodes"];
                List <PerbelanjaanSebenar>           data     = (List <PerbelanjaanSebenar>)Session["PerbelanjaanData"];
                List <PerbelanjaanSebenarTreeHelper> TreeData = new List <PerbelanjaanSebenarTreeHelper>();
                if (data.Count > 0)
                {
                    TreeData = data.OrderBy(x => x.BudgetAccount).Select(x =>
                                                                         new PerbelanjaanSebenarTreeHelper()
                    {
                        BudgetAccount = x.BudgetAccount,
                        Description   = x.Description,
                        BudgetAmount  = Convert.ToDouble(x.BudgetAmount),
                        BudgetYear    = Convert.ToDouble(x.BudgetYear),
                    }).ToList();

                    if (SelectedNodes == null || SelectedNodes.Count == 0)
                    {
                        Session["SelectedNodes"] = new List <string>();
                        SelectedNodes            = new List <string>();
                    }
                    else
                    {
                        //while(TreeData.Where(x=>x.IsExpanded).Select(x=>x).Count() < SelectedNodes.Count)
                        //{
                        for (int i = 0; i < TreeData.Count; i++)
                        {
                            if (SelectedNodes.Contains(TreeData[i].BudgetAccount))
                            {
                                //TreeData[i].IsExpanded = true;
                                foreach (PerbelanjaanSebenar sd in data.Where(x => x.BudgetAccount == TreeData[i].BudgetAccount).OrderByDescending(x => x.BudgetAccount))
                                {
                                    PerbelanjaanSebenarTreeHelper objSH = new PerbelanjaanSebenarTreeHelper()
                                    {
                                        BudgetAccount = sd.BudgetAccount,
                                        Description   = sd.Description,
                                        BudgetAmount  = Convert.ToDouble(sd.BudgetAmount),
                                        BudgetYear    = Convert.ToDouble(sd.BudgetYear),
                                    };
                                    TreeData.Insert(i + 1, objSH);
                                }
                            }
                        }
                        //}
                    }
                }
                Session["PerbelanjaanDataTree"] = TreeData;
                BindGrid();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
        //protected void btnCancel_Click(object sender, EventArgs e)
        //{
        //    ClearPageData();
        //    Session["SelectedAccountCode"] = null;
        //}

        protected void gvOpenbudget_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    PerbelanjaanSebenarTreeHelper rowItem = (PerbelanjaanSebenarTreeHelper)e.Row.DataItem;
                    //((Label)e.Row.FindControl("lblIndent")).Width = Unit.Pixel(rowItem.Level * 30);
                    //((Label)e.Row.FindControl("lblDetailCode")).Text = rowItem.DetailCode;
                    //int width = rowItem.BudgetAccKey * 30;

                    string strHTML = string.Empty;

                    //if (rowItem.BudgetAccKey > 0)
                    //{
                    //    if (SelectedNodes.Contains(rowItem.BudgetAccount))
                    //        strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-minus-square pull-right\"></i></label> ";
                    //    else
                    //        strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-plus-square pull-right\"></i></label> ";
                    //}
                    //else
                    //    strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i></i></label> ";

                    LinkButton btnExpand = ((LinkButton)e.Row.FindControl("btnExpand"));
                    btnExpand.Text = "<div>" + strHTML + rowItem.BudgetAccount + "</div>";

                    if (rowItem.BudgetAccount != string.Empty)
                    {
                        ((LinkButton)e.Row.FindControl("lbAddItem")).Visible = false;
                    }
                    if (rowItem.BudgetAccount == string.Empty)
                    {
                        ((LinkButton)e.Row.FindControl("lbMakeRoot")).Visible = false;
                    }
                    if (rowItem.BudgetAccount == string.Empty)
                    {
                        ((LinkButton)e.Row.FindControl("btnExpand")).Visible  = false;
                        ((LinkButton)e.Row.FindControl("lbEit")).Visible      = false;
                        ((LinkButton)e.Row.FindControl("lbDelete")).Visible   = false;
                        ((LinkButton)e.Row.FindControl("lbCut")).Visible      = false;
                        ((LinkButton)e.Row.FindControl("lbPaste")).Visible    = false;
                        ((LinkButton)e.Row.FindControl("lbMakeRoot")).Visible = false;
                        ((LinkButton)e.Row.FindControl("lbAddChild")).Visible = false;
                    }

                    if (Session["SelectedAccountCode"] != null && ((AccountCode)Session["SelectedAccountCode"]).AccountCode1 == rowItem.BudgetAccount)
                    {
                        e.Row.Style["background-color"] = "skyblue";
                    }

                    var span = ((HtmlGenericControl)e.Row.Cells[2].FindControl("CustomStatus"));
                    //if (rowItem.Status == "A")
                    //{
                    //    //span.Attributes["class"] = "label label-success";
                    //    //span.InnerHtml = "<i class=\"fa fa-flag green bigger-150 tooltip-success\" data-rel=\"tooltip\" data-placement=\"right\" title=\"Active\"></i>";
                    //    span.InnerHtml = "<span class=\"label label-sm label-success arrowed-in arrowed-in-right tooltip-success\" " +
                    //        "data-rel=\"tooltip\" data-placement=\"right\" title=\"Active Status. All operation has been enabled.\">Active</span>";
                    //}
                    //else if (rowItem.Status == "D")
                    //{
                    //    //span.InnerHtml = "<i class=\"fa fa-flag red bigger-150 tooltip-error\" data-rel=\"tooltip\" data-placement=\"right\" title=\"Inactive\"></i>";
                    //    span.InnerHtml = "<span class=\"label label-sm label-danger arrowed-in arrowed-in-right tooltip-error\" " +
                    //        "data-rel=\"tooltip\" data-placement=\"right\" title=\"Inactive Status. All operation has been disabled.\">Inactive</span>";
                    //}
                }
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }