protected void Button1_Click(object sender, EventArgs e)
    {
        RobotTableAdapters.CollateralType_GuaranteeTableAdapter robot = new RobotTableAdapters.CollateralType_GuaranteeTableAdapter();

        //initialize values
        int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]);
        int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);
        String collateraldetails_id = Request.QueryString["collateraldetails_id"];
        int collateraldetailsid = Convert.ToInt32(Request.QueryString["collateraldetails_id"]);

        
        //insert values into CollateralType_Cash  and retrieve max id as collateralDetailsId
        robot.Update(guarantorName.Text, guarantorAddress.Text, guarantorBizAddress.Text, obligorRelationship.Text, telephoneNo.Text, Convert.ToInt32(meansOfID.SelectedValue), collateralSupportingGuaranty.Text, collateralId, Convert.ToInt32(collateraldetails_id));
        //robot.Update(varValueOfCash, varTypeOfCashGuarantee, AccountLien.Text, DateTime.Now, -1, collateralId, Smart.GetEmployeeID(), "NULL", collateraldetailsid);
        hiddenDetailsId.Text = collateraldetailsid.ToString();

        //enable and move focus to next tab, disable current tab
        ASPxPageControl1.TabPages[1].Enabled = true;


        ASPxPageControl1.ActiveTabIndex = 1;
        CheckBoxList1_Load();
                  
       
          
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        RobotTableAdapters.CollateralType_GuaranteeTableAdapter robot = new RobotTableAdapters.CollateralType_GuaranteeTableAdapter();

        //initialize values
        int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]);
        int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);

        //insert values into CollateralType_Cash  and retrieve max id as collateralDetailsId
        int collateralDetailsId = Convert.ToInt32(robot.proc_insertGuarantee(guarantorName.Text, guarantorAddress.Text, guarantorBizAddress.Text, obligorRelationship.Text,
                                   telephoneNo.Text, Convert.ToInt32(meansOfID.SelectedValue), collateralSupportingGuaranty.Text, collateralId));

         hiddenDetailsId.Text = collateralDetailsId.ToString();
        //hiddenDetailsId.Text = "9";

        //enable and move focus to next tab, disable current tab
        ASPxPageControl1.TabPages[1].Enabled = true;


        ASPxPageControl1.ActiveTabIndex = 1;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {  ASPxPageControl1.TabPages[0].Enabled = true;
            ASPxPageControl1.TabPages[1].Enabled = false;
            ASPxPageControl1.TabPages[2].Enabled = false;
            ASPxPageControl1.TabPages[3].Enabled = false;

            ASPxPageControl1.ActiveTabIndex = 0;
            int collateraldetailsid = Convert.ToInt32(Request.QueryString["collateraldetails_id"]);

            //this code is for population of fields when update mode is set
            RobotTableAdapters.CollateralType_GuaranteeTableAdapter Engine = new RobotTableAdapters.CollateralType_GuaranteeTableAdapter();

            DataTable returnedData = Engine.getGuranteeById(Convert.ToInt32(collateraldetailsid));

            //TextBOXES
            guarantorName.Text = returnedData.Rows[0]["guarantor_name"].ToString();
            collateralSupportingGuaranty.Text = returnedData.Rows[0]["collateralSupportingGuarantee"].ToString();
            obligorRelationship.Text = returnedData.Rows[0]["relationship"].ToString();
            //DateTime dt;
            //dt = Convert.ToDateTime(returnedData.Rows[0]["DateOfMaturity"].ToString());
            //DateOfMaturity.Value = ((DateTime)dt).ToString("MM/dd/yyyy");

            guarantorAddress.Text = returnedData.Rows[0]["address_residential"].ToString();
            guarantorBizAddress.Text = returnedData.Rows[0]["address_business"].ToString();
            telephoneNo.Text = returnedData.Rows[0]["telephone"].ToString();

            if (returnedData.Rows[0]["documenttype_id"].ToString()!="-1")
                documenttype_id.SelectedValue = returnedData.Rows[0]["documenttype_id"].ToString();
            //DROPDOWN
            if (returnedData.Rows[0]["meansOfID"].ToString() != "-1")
                meansOfID.SelectedValue = returnedData.Rows[0]["meansOfID"].ToString();
        }

        CheckBoxList1_Load();
        
    }