private void BindCustomer()
        {
            //Dictionary<string, string> genDictParent = new Dictionary<string, string>();
            //Dictionary<string, string> genDictRM = new Dictionary<string, string>();
            //Dictionary<string, string> genDictReassignRM = new Dictionary<string, string>();

            Dictionary <string, string> advisorBranchList = new Dictionary <string, string>();
            string            customer        = "";
            AdvisorBranchBo   adviserBranchBo = new AdvisorBranchBo();
            List <CustomerVo> customerList    = new List <CustomerVo>();

            //
            List <CustomerVo> allcustomerList = new List <CustomerVo>();

            RMVo      customerRMVo     = new RMVo();
            DataTable dtRMCustomer     = new DataTable();
            DataTable dtRMCustomerFull = new DataTable();

            try
            {
                DropDownList ddl = new DropDownList();
                Label        lbl = new Label();

                //customer = Session["Customer"].ToString();
                //if (customer.ToLower().Trim() == "find customer" || customer.ToLower().Trim() == "")
                //    customer = "";

                rmVo = (RMVo)Session["rmVo"];

                adviserVo = (AdvisorVo)Session["advisorVo"];

                //if (hdnCurrentPage.Value.ToString() != "")
                //{
                //    mypager.CurrentPage = Int32.Parse(hdnCurrentPage.Value.ToString());
                //    hdnCurrentPage.Value = "";
                //}

                int Count = 0;

                // Search Term is input into this hidden field
                //hdnNameFilter.Value = customer;

                //customerList = adviserBranchBo.(adviserVo.advisorId, mypager.CurrentPage, out Count, hdnSort.Value, hdnNameFilter.Value, hdnAreaFilter.Value, hdnPincodeFilter.Value, hdnParentFilter.Value, hdnRMFilter.Value, out genDictParent, out genDictRM, out genDictReassignRM);
                customerList    = adviserBranchBo.GetAdviserCustomerListForAssociation(int.Parse(hndBranchIdFilter.Value.ToString()), adviserVo.advisorId, 0, out Count, hdnSort.Value, hdnNameFilter.Value, hdnBranchFilter.Value, hdnRMNameFilter.Value, hdnAreaFilter.Value, hdnCityFilter.Value, out advisorBranchList);
                allcustomerList = adviserBranchBo.GetAdviserCustomerListForAssociation(int.Parse(hndBranchIdFilter.Value.ToString()), adviserVo.advisorId, 0, out Count, hdnSort.Value, hdnNameFilter.Value, hdnBranchFilter.Value, hdnRMNameFilter.Value, hdnAreaFilter.Value, hdnCityFilter.Value, out advisorBranchList);
                // lblTotalRows.Text = hdnRecordCount.Value = Count.ToString();

                #region forcustomerlist
                dtRMCustomer.Columns.Add("CustomerId");
                dtRMCustomer.Columns.Add("UserId");
                dtRMCustomer.Columns.Add("RMId");
                dtRMCustomer.Columns.Add("Parent");
                dtRMCustomer.Columns.Add("Cust_Comp_Name");
                dtRMCustomer.Columns.Add("PAN Number");
                dtRMCustomer.Columns.Add("Mobile Number");
                dtRMCustomer.Columns.Add("Phone Number");
                dtRMCustomer.Columns.Add("Email");
                dtRMCustomer.Columns.Add("Address");
                dtRMCustomer.Columns.Add("Area");
                dtRMCustomer.Columns.Add("City");
                dtRMCustomer.Columns.Add("Pincode");
                dtRMCustomer.Columns.Add("RMName");
                dtRMCustomer.Columns.Add("BranchName");
                dtRMCustomer.Columns.Add("BranchId");
                dtRMCustomer.Columns.Add("CustomerType");
                #endregion


                #region forallcustomerlist
                dtRMCustomerFull.Columns.Add("CustomerId");
                dtRMCustomerFull.Columns.Add("UserId");
                dtRMCustomerFull.Columns.Add("RMId");
                dtRMCustomerFull.Columns.Add("Parent");
                dtRMCustomerFull.Columns.Add("Cust_Comp_Name");
                dtRMCustomerFull.Columns.Add("PAN Number");
                dtRMCustomerFull.Columns.Add("Mobile Number");
                dtRMCustomerFull.Columns.Add("Phone Number");
                dtRMCustomerFull.Columns.Add("Email");
                dtRMCustomerFull.Columns.Add("Address");
                dtRMCustomerFull.Columns.Add("Area");
                dtRMCustomerFull.Columns.Add("City");
                dtRMCustomerFull.Columns.Add("Pincode");
                dtRMCustomerFull.Columns.Add("RMName");
                dtRMCustomerFull.Columns.Add("BranchName");
                dtRMCustomerFull.Columns.Add("BranchId");
                dtRMCustomerFull.Columns.Add("CustomerType");
                #endregion

                if (customerList == null)
                {
                    //DataRow drRMCustomer = dtRMCustomer.NewRow();
                    //drRMCustomer[0] = string.Empty;
                    //drRMCustomer[1] = string.Empty;
                    //drRMCustomer[2] = string.Empty;
                    //drRMCustomer[3] = string.Empty;
                    //drRMCustomer[4] = string.Empty;
                    //drRMCustomer[5] = string.Empty;
                    //drRMCustomer[6] = string.Empty;
                    //drRMCustomer[7] = string.Empty;
                    //drRMCustomer[8] = string.Empty;
                    //drRMCustomer[9] = string.Empty;
                    //drRMCustomer[10] = string.Empty;
                    //drRMCustomer[11] = string.Empty;
                    //drRMCustomer[12] = string.Empty;
                    //drRMCustomer[13] = string.Empty;
                    //drRMCustomer[14] = string.Empty;
                    //drRMCustomer[15] = string.Empty;
                    //drRMCustomer[16] = string.Empty;
                    //dtRMCustomer.Rows.Add(drRMCustomer);

                    //gvAssociation.DataSource = dtRMCustomer;
                    //gvAssociation.DataBind();
                    //gvAssociation.Columns[4].Visible = false;
                    ////gvAssociation.Columns[5].Visible = false;
                    //gvAssociation.Columns[8].Visible = false;

                    hdnRecordCount.Value = "0";

                    ErrorMessage.Visible = true;
                    trPager.Visible      = false;
                    // lblTotalRows.Visible = false;
                    lblCurrentPage.Visible = false;
                    btnReassignRM.Visible  = false;
                    trReassignRM.Visible   = false;
                }
                else
                {
                    if (rdReassignRM.Checked == true)
                    {
                        trReassignRM.Visible  = true;
                        btnReassignRM.Visible = true;
                    }

                    ErrorMessage.Visible = false;
                    //trPager.Visible = true;
                    // lblTotalRows.Visible = true;
                    //lblCurrentPage.Visible = true;

                    DataRow drRMCustomer;
                    DataRow drRMCustomerALL;

                    #region customer list according to pagecount

                    for (int i = 0; i < customerList.Count; i++)
                    {
                        drRMCustomer             = dtRMCustomer.NewRow();
                        customerVo               = new CustomerVo();
                        customerVo               = customerList[i];
                        drRMCustomer[0]          = customerVo.CustomerId.ToString();
                        drRMCustomer[1]          = customerVo.UserId.ToString();
                        drRMCustomer[2]          = customerVo.RmId.ToString();
                        drRMCustomer["BranchId"] = customerVo.BranchId.ToString();
                        if (customerVo.ParentCustomer != null)
                        {
                            drRMCustomer[3] = customerVo.ParentCustomer.ToString();
                        }

                        drRMCustomer[4] = customerVo.FirstName.ToString() + " " + customerVo.MiddleName.ToString() + " " + customerVo.LastName.ToString();

                        //if (customerVo.Type.ToUpper().ToString() == "IND" || customerVo.Type == "")
                        //{
                        //    if (customerVo.ParentCustomer != null)
                        //    {
                        //        drRMCustomer[3] = customerVo.ParentCustomer.ToString();
                        //    }
                        //    else
                        //    {
                        //        drRMCustomer[3] = customerVo.FirstName.ToString() + " " + customerVo.MiddleName.ToString() + " " + customerVo.LastName.ToString();
                        //    }
                        //    drRMCustomer[4] = customerVo.FirstName.ToString() + " " + customerVo.MiddleName.ToString() + " " + customerVo.LastName.ToString();
                        //}
                        //else if (customerVo.Type.ToUpper().ToString() == "NIND")
                        //{
                        //    if (customerVo.ParentCompany != null)
                        //    {
                        //        drRMCustomer[3] = customerVo.ParentCompany.ToString();
                        //    }
                        //    else
                        //    {
                        //        drRMCustomer[3] = customerVo.CompanyName.ToString();
                        //    }
                        //    drRMCustomer[4] = customerVo.CompanyName.ToString();
                        //}
                        if (customerVo.PANNum != null)
                        {
                            drRMCustomer[5] = customerVo.PANNum.ToString();
                        }
                        else
                        {
                            drRMCustomer[5] = "";
                        }
                        drRMCustomer[6] = customerVo.Mobile1.ToString();
                        drRMCustomer[7] = customerVo.ResISDCode.ToString() + "-" + customerVo.ResSTDCode.ToString() + "-" + customerVo.ResPhoneNum.ToString();
                        drRMCustomer[8] = customerVo.Email.ToString();
                        if (customerVo.Adr1Line1 == null)
                        {
                            customerVo.Adr1Line1 = "";
                        }
                        if (customerVo.Adr1Line2 == null)
                        {
                            customerVo.Adr1Line2 = "";
                        }
                        if (customerVo.Adr1Line3 == null)
                        {
                            customerVo.Adr1Line3 = "";
                        }
                        if (customerVo.Adr1City == null)
                        {
                            customerVo.Adr1City = "";
                        }
                        if (customerVo.Adr1Line1.ToString() == "" && customerVo.Adr1Line2.ToString() == "")
                        {
                            drRMCustomer[9] = "-";
                        }
                        else if (customerVo.Adr1Line1.ToString() == "" && customerVo.Adr1Line2.ToString() != "")
                        {
                            drRMCustomer[9] = customerVo.Adr1Line2.ToString();
                        }
                        else if (customerVo.Adr1Line1.ToString() != "" && customerVo.Adr1Line2.ToString() == "")
                        {
                            drRMCustomer[9] = customerVo.Adr1Line1.ToString();
                        }
                        else if (customerVo.Adr1Line1.ToString() != "" && customerVo.Adr1Line2.ToString() != "")
                        {
                            drRMCustomer[9] = customerVo.Adr1Line1.ToString() + "," + customerVo.Adr1Line2.ToString() + "," + customerVo.Adr1Line3.ToString() + "," + customerVo.Adr1City.ToString();
                        }

                        drRMCustomer[10] = customerVo.Adr1Line3.ToString() + "," + customerVo.Adr1City.ToString();
                        if (customerVo.Adr1City.ToString() != "" && customerVo.Adr1Line3.ToString() != "")
                        {
                            drRMCustomer[11] = customerVo.Adr1City.ToString() + "," + customerVo.Adr1Line3.ToString();
                        }
                        else if (customerVo.Adr1City.ToString() != "" && customerVo.Adr1Line3.ToString() == "")
                        {
                            drRMCustomer[11] = customerVo.Adr1City.ToString();
                        }
                        else if (customerVo.Adr1City.ToString() == "" && customerVo.Adr1Line3.ToString() != "")
                        {
                            drRMCustomer[11] = customerVo.Adr1Line3.ToString();
                        }
                        else if (customerVo.Adr1City.ToString() == "" && customerVo.Adr1Line3.ToString() == "")
                        {
                            drRMCustomer[11] = "-";
                        }
                        drRMCustomer[12] = customerVo.Adr1PinCode.ToString();
                        drRMCustomer[13] = customerVo.AssignedRM.ToString();
                        drRMCustomer[14] = customerVo.BranchName.ToString();
                        drRMCustomer[16] = customerVo.UserType.ToString();
                        dtRMCustomer.Rows.Add(drRMCustomer);
                    }

                    #endregion

                    #region customerlist full

                    for (int i = 0; i < allcustomerList.Count; i++)
                    {
                        drRMCustomerALL             = dtRMCustomerFull.NewRow();
                        customerVo                  = new CustomerVo();
                        customerVo                  = allcustomerList[i];
                        drRMCustomerALL[0]          = customerVo.CustomerId.ToString();
                        drRMCustomerALL[1]          = customerVo.UserId.ToString();
                        drRMCustomerALL[2]          = customerVo.RmId.ToString();
                        drRMCustomerALL["BranchId"] = customerVo.BranchId.ToString();
                        if (customerVo.ParentCustomer != null)
                        {
                            drRMCustomerALL[3] = customerVo.ParentCustomer.ToString();
                        }

                        drRMCustomerALL[4] = customerVo.FirstName.ToString() + " " + customerVo.MiddleName.ToString() + " " + customerVo.LastName.ToString();
                        if (customerVo.PANNum != null)
                        {
                            drRMCustomerALL[5] = customerVo.PANNum.ToString();
                        }
                        else
                        {
                            drRMCustomerALL[5] = "";
                        }
                        drRMCustomerALL[6] = customerVo.Mobile1.ToString();
                        drRMCustomerALL[7] = customerVo.ResISDCode.ToString() + "-" + customerVo.ResSTDCode.ToString() + "-" + customerVo.ResPhoneNum.ToString();
                        drRMCustomerALL[8] = customerVo.Email.ToString();
                        if (customerVo.Adr1Line1 == null)
                        {
                            customerVo.Adr1Line1 = "";
                        }
                        if (customerVo.Adr1Line2 == null)
                        {
                            customerVo.Adr1Line2 = "";
                        }
                        if (customerVo.Adr1Line3 == null)
                        {
                            customerVo.Adr1Line3 = "";
                        }
                        if (customerVo.Adr1City == null)
                        {
                            customerVo.Adr1City = "";
                        }
                        if (customerVo.Adr1Line1.ToString() == "" && customerVo.Adr1Line2.ToString() == "")
                        {
                            drRMCustomerALL[9] = "-";
                        }
                        else if (customerVo.Adr1Line1.ToString() == "" && customerVo.Adr1Line2.ToString() != "")
                        {
                            drRMCustomerALL[9] = customerVo.Adr1Line2.ToString();
                        }
                        else if (customerVo.Adr1Line1.ToString() != "" && customerVo.Adr1Line2.ToString() == "")
                        {
                            drRMCustomerALL[9] = customerVo.Adr1Line1.ToString();
                        }
                        else if (customerVo.Adr1Line1.ToString() != "" && customerVo.Adr1Line2.ToString() != "")
                        {
                            drRMCustomerALL[9] = customerVo.Adr1Line1.ToString() + "," + customerVo.Adr1Line2.ToString() + "," + customerVo.Adr1Line3.ToString() + "," + customerVo.Adr1City.ToString();
                        }

                        drRMCustomerALL[10] = customerVo.Adr1Line3.ToString() + "," + customerVo.Adr1City.ToString();
                        if (customerVo.Adr1City.ToString() != "" && customerVo.Adr1Line3.ToString() != "")
                        {
                            drRMCustomerALL[11] = customerVo.Adr1City.ToString() + "," + customerVo.Adr1Line3.ToString();
                        }
                        else if (customerVo.Adr1City.ToString() != "" && customerVo.Adr1Line3.ToString() == "")
                        {
                            drRMCustomerALL[11] = customerVo.Adr1City.ToString();
                        }
                        else if (customerVo.Adr1City.ToString() == "" && customerVo.Adr1Line3.ToString() != "")
                        {
                            drRMCustomerALL[11] = customerVo.Adr1Line3.ToString();
                        }
                        else if (customerVo.Adr1City.ToString() == "" && customerVo.Adr1Line3.ToString() == "")
                        {
                            drRMCustomerALL[11] = "-";
                        }
                        drRMCustomerALL[12] = customerVo.Adr1PinCode.ToString();
                        drRMCustomerALL[13] = customerVo.AssignedRM.ToString();
                        drRMCustomerALL[14] = customerVo.BranchName.ToString();
                        drRMCustomerALL[16] = customerVo.UserType.ToString();
                        dtRMCustomerFull.Rows.Add(drRMCustomerALL);
                    }

                    #endregion

                    gvAssociations.DataSource = dtRMCustomer;
                    gvAssociations.DataBind();

                    #region customerlist

                    if (Cache["gvAssociation" + adviserVo.advisorId] == null)
                    {
                        Cache.Insert("gvAssociation" + adviserVo.advisorId, dtRMCustomer);
                    }
                    else
                    {
                        Cache.Remove("gvAssociation" + adviserVo.advisorId);
                        Cache.Insert("gvAssociation" + adviserVo.advisorId, dtRMCustomer);
                    }

                    #endregion

                    #region customerlist full
                    if (Cache["gvAssociationFull" + adviserVo.advisorId] == null)
                    {
                        Cache.Insert("gvAssociationFull" + adviserVo.advisorId, dtRMCustomerFull);
                    }
                    else
                    {
                        Cache.Remove("gvAssociationFull" + adviserVo.advisorId);
                        Cache.Insert("gvAssociationFull" + adviserVo.advisorId, dtRMCustomerFull);
                    }

                    #endregion



                    gvAssociations.Columns[4].Visible = false;
                    //gvAssociation.Columns[5].Visible = false;
                    gvAssociations.Columns[8].Visible = false;
                    //ReAssignRMControl(genDictRM);

                    //if (genDictParent.Count > 0)
                    //{
                    //    DropDownList ddlParent = GetParentDDL();
                    //    if (ddlParent != null)
                    //    {
                    //        ddlParent.DataSource = genDictParent;
                    //        ddlParent.DataTextField = "Key";
                    //        ddlParent.DataValueField = "Value";
                    //        ddlParent.DataBind();
                    //        ddlParent.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select", "Select"));
                    //    }
                    //    if (hdnParentFilter.Value != "")
                    //    {
                    //        ddlParent.SelectedValue = hdnParentFilter.Value.ToString();
                    //    }
                    //}

                    if (advisorBranchList.Count > 0)
                    {
                        if (ddlAdvisorBranchList != null)
                        {
                            ddlAdvisorBranchList.DataSource     = advisorBranchList;
                            ddlAdvisorBranchList.DataTextField  = "Value";
                            ddlAdvisorBranchList.DataValueField = "Key";
                            ddlAdvisorBranchList.DataBind();
                            ddlAdvisorBranchList.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select", "0"));
                        }
                        if (hdnRMFilter.Value != "")
                        {
                            ddlAdvisorBranchList.SelectedIndex = 0;
                        }
                    }
                    if (advisorBranchList.Count > 0 && !Page.IsPostBack)
                    {
                        if (ddlAdvisorBranchList != null)
                        {
                            ddlBranchList.DataSource     = advisorBranchList;
                            ddlBranchList.DataTextField  = "Value";
                            ddlBranchList.DataValueField = "Key";
                            ddlBranchList.DataBind();
                            ddlBranchList.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select a Branch", "0"));
                        }
                        if (hdnRMFilter.Value != "")
                        {
                            ddlBranchList.SelectedIndex = 0;
                        }
                    }
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdviserCustomer.ascx.cs:BindCustomer()");
                object[] objects = new object[3];
                objects[0]   = rmVo;
                objects[1]   = customerVo;
                objects[2]   = customerList;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }