private void bindData(int index)
        {
            try
            {
                //LAY DANH SACH CAC QUOC GIA RA
                dsGroup = new DataTable();
                dsPhieuNhapXuat = new DataTable();
                clsPhieuNhap objPhieuNhap = new clsPhieuNhap();
                clsPhieuXuat objPhieuXuat = new clsPhieuXuat();

                if (sLoaiPhieu == "0")
                {
                    objPhieuNhap.So_Phieu = sKey;
                    dsGroup = objPhieuNhap.Select_ChiTiet();
                    objPhieuNhap.PhieuNhap_Id = sPhieu_Id;
                    dsPhieuNhapXuat = objPhieuNhap.Select();
                    if (dsPhieuNhapXuat.Rows.Count > 0)
                    {
                        if (Convert.ToInt16(dsPhieuNhapXuat.Rows[0]["LoaiNhapXuat_Id"]) == 1)
                        {
                            txtLoaiNhapXuat.Text = "Phiếu nhập";
                        }
                        else
                        {
                            txtLoaiNhapXuat.Text = "Phiếu xuất";
                        }
                        txtSoPhieu.Text = dsPhieuNhapXuat.Rows[0]["so_phieu"].ToString();
                        txtLyDoNhap.Text = dsPhieuNhapXuat.Rows[0]["LyDoNhap"].ToString();
                        txtDienGiai.Text = dsPhieuNhapXuat.Rows[0]["Dien_Giai"].ToString();
                        dtpNgayNhapXuat.SelectedDate = Convert.ToDateTime(dsPhieuNhapXuat.Rows[0]["Ngay_Nhap"]);
                        if (dsPhieuNhapXuat.Rows[0]["DuAn_DanhRieng_Id"] == DBNull.Value)
                        {
                            txtDuAnDanhRieng.Text = "";
                        }
                        else
                        {
                            txtDuAnDanhRieng.Text = dsPhieuNhapXuat.Rows[0]["DuAn_DanhRieng_Id"].ToString();
                        }
                        txtNhanVienBan.Text = dsPhieuNhapXuat.Rows[0]["TenDayDu"].ToString();
                        txtNhanVienDoiTac.Text = dsPhieuNhapXuat.Rows[0]["TenDoiTac"].ToString();
                    }
                }
                else
                {
                    objPhieuXuat.So_Phieu = sKey;
                    dsGroup = objPhieuXuat.Select_ChiTiet();
                    objPhieuXuat.PhieuXuat_Id = sPhieu_Id;
                    dsPhieuNhapXuat = objPhieuXuat.Select();
                    if (dsPhieuNhapXuat.Rows.Count > 0)
                    {
                        if (Convert.ToInt16(dsPhieuNhapXuat.Rows[0]["LoaiNhapXuat_Id"]) == 1)
                        {
                            txtLoaiNhapXuat.Text = "Phiếu nhập";
                        }
                        else
                        {
                            txtLoaiNhapXuat.Text = "Phiếu xuất";
                        }
                        txtSoPhieu.Text = dsPhieuNhapXuat.Rows[0]["so_phieu"].ToString();
                        txtLyDoNhap.Text = dsPhieuNhapXuat.Rows[0]["LyDoXuat"].ToString();
                        txtDienGiai.Text = dsPhieuNhapXuat.Rows[0]["Dien_Giai"].ToString();
                        dtpNgayNhapXuat.SelectedDate = Convert.ToDateTime(dsPhieuNhapXuat.Rows[0]["Ngay_Xuat"]);
                        if (dsPhieuNhapXuat.Rows[0]["DuAn_Id"] == DBNull.Value)
                        {
                            txtDuAnDanhRieng.Text = "";
                        }
                        else
                        {
                            txtDuAnDanhRieng.Text = dsPhieuNhapXuat.Rows[0]["DuAn_Id"].ToString();
                        }
                        txtNhanVienBan.Text = dsPhieuNhapXuat.Rows[0]["TenDayDu"].ToString();
                        txtNhanVienDoiTac.Text = dsPhieuNhapXuat.Rows[0]["TenDoiTac"].ToString();
                    }
                }
                objPhieuNhap.So_Phieu = "0";

                m_grid.EditIndex = index;
                m_grid.DataSource = dsGroup;
                bool add = false;
                if (dsGroup.Rows.Count <= 0)
                {
                    dsGroup.Rows.Add(dsGroup.NewRow());
                    add = true;

                }
                //
                m_grid.DataBind();
                if (add)
                    m_grid.Rows[0].Visible = false;
                if (m_grid.Rows.Count > 0)
                {
                    string confirm = "return confirm('Bạn thật sự muốn xóa row này?')";

                    for (int i = 0; i < m_grid.Rows.Count; i++)
                    {
                        GridViewRow row = m_grid.Rows[i];
                        LinkButton lbutton1 = (LinkButton)row.FindControl("cmdDelete");
                        if (lbutton1 != null)
                        {
                            lbutton1.Visible = D_Option;
                            lbutton1.Attributes.Add("onclick", confirm);
                            //lbutton1.Enabled = D_Option;
                        }

                        LinkButton lbutton2 = (LinkButton)row.FindControl("cmdEdit");
                        if (lbutton2 != null)
                            lbutton2.Visible = U_Option;
                    }
                }

                //XET QUYETN CHO CHUC NANG INSERT
                GridViewRow row1 = m_grid.FooterRow;
                if (row1 != null)
                {
                    row1.Visible = I_Option;
                }
            }
            catch (Exception ex)
            {
            }
        }