private void BindGridDetail()
        {
            var lstBudgetDetail = new List <view_Budget_open_detail>();

            try
            {
                cBudget_open oBudget_open = new cBudget_open();
                _strMessage          = string.Empty;
                _strCriteria         = " and budget_open_doc = '" + txtbudget_open_doc.Text + "' order by item_detail_code";
                lstBudgetDetail      = oBudget_open.GETDETAILS(_strCriteria);
                GridView1.DataSource = lstBudgetDetail;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                this.bIsGridDetailEmpty = false;
                if (!lstBudgetDetail.Any())
                {
                    this.bIsGridDetailEmpty = true;
                    EmptyGridFix(GridView1);
                }
                else
                {
                    GridView1.DataBind();
                }
            }
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType.Equals(DataControlRowType.Header))
            {
                for (int iCol = 0; iCol < e.Row.Cells.Count; iCol++)
                {
                    e.Row.Cells[iCol].Attributes.Add("class", "table_h");
                    e.Row.Cells[iCol].Wrap = false;
                }
            }
            else if (e.Row.RowType.Equals(DataControlRowType.DataRow) || e.Row.RowState.Equals(DataControlRowState.Alternate))
            {
                #region Set datagrid row color
                string strEvenColor, strOddColor, strMouseOverColor;
                strEvenColor      = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Even"].ToString();
                strOddColor       = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Odd"].ToString();
                strMouseOverColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["MouseOver"].ToString();

                e.Row.Style.Add("valign", "top");
                e.Row.Style.Add("cursor", "hand");
                e.Row.Attributes.Add("onMouseOver", "this.style.backgroundColor='" + strMouseOverColor + "'");

                if (e.Row.RowState.Equals(DataControlRowState.Alternate))
                {
                    e.Row.Attributes.Add("bgcolor", strOddColor);
                    e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strOddColor + "'");
                }
                else
                {
                    e.Row.Attributes.Add("bgcolor", strEvenColor);
                    e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strEvenColor + "'");
                }
                #endregion

                DataRowView dv = (DataRowView)(e.Row.DataItem);

                Label lblNo = (Label)e.Row.FindControl("lblNo");
                int   nNo   = (GridView1.PageSize * GridView1.PageIndex) + e.Row.RowIndex + 1;
                lblNo.Text = nNo.ToString();
                Label lblbudget_plan_code    = (Label)e.Row.FindControl("lblbudget_plan_code");
                Label lblbudget_open_name    = (Label)e.Row.FindControl("lblbudget_open_name");
                Label lblapprove_head_status = (Label)e.Row.FindControl("lblapprove_head_status");



                #region set ImageView
                ImageButton imgView = (ImageButton)e.Row.FindControl("imgView");
                //imgView.Attributes.Add("onclick", "OpenPopUp('950px','350px','94%','แสดงข้อมูลผังงบประมาณ','budget_open_view.aspx?mode=view&budget_plan_code=" +
                //                                                lblbudget_plan_code.Text + "','1');return false;");
                imgView.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgView"].Rows[0]["img"].ToString();
                imgView.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgView"].Rows[0]["title"].ToString());
                #endregion

                #region set Image Edit & Delete
                ImageButton imgEdit = (ImageButton)e.Row.FindControl("imgEdit");
                //Label lblCanEdit = (Label)e.Row.FindControl("lblCanEdit");
                //imgEdit.Attributes.Add("onclick", "OpenPopUp('900px','350px','90%','แก้ไข" + base.PageDes + "','budget_open_control.aspx?budget_type=" + this.BudgetType + "&mode=edit&budget_plan_code="
                //                                            + lblbudget_plan_code.Text + "&page=" + GridView1.PageIndex.ToString() + "&canEdit=Y','1');return false;");
                imgEdit.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgEdit"].Rows[0]["img"].ToString();
                imgEdit.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgEdit"].Rows[0]["title"].ToString());

                ImageButton imgDelete = (ImageButton)e.Row.FindControl("imgDelete");
                imgDelete.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["img"].ToString();
                imgDelete.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["title"].ToString());
                imgDelete.Attributes.Add("onclick", "return confirm(\"คุณต้องการลบผังงบประมาณ  : " + lblbudget_plan_code.Text + " ?\");");
                #endregion


                var rptItem = (Repeater)e.Row.FindControl("rptItem");
                _strCriteria = " and budget_open_doc = '" + dv["budget_open_doc"].ToString() + "' ";
                var oBudget_open = new cBudget_open();
                var list         = oBudget_open.GETDETAILS(_strCriteria);
                rptItem.DataSource = list;
                rptItem.DataBind();

                if (dv["approve_head_status"].ToString() == "P")
                {
                    lblapprove_head_status.Text = "รออนุมัติ";
                }
                else if (dv["approve_head_status"].ToString() == "A")
                {
                    lblapprove_head_status.Text = "อนุมัติ";
                }
                else if (dv["approve_head_status"].ToString() == "C")
                {
                    lblapprove_head_status.Text = "ยกเลิกรายการ";
                }


                #region check user can edit/delete
                imgEdit.Visible   = base.IsUserEdit;
                imgDelete.Visible = base.IsUserDelete;
                #endregion

                if (this.MajorLock == "Y")
                {
                    imgEdit.Visible   = false;
                    imgDelete.Visible = false;
                    if (dv["approve_head_status"].ToString() == "P")
                    {
                        imgEdit.Visible   = true;
                        imgDelete.Visible = true;
                    }
                }
            }
        }