private void BindAg_WFP3_PaymentBMP() { FormView fv = fvAg_WFP3_PaymentBMP; using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext()) { var a = from b in wDataContext.form_wfp3_paymentBMPs.Where(w => w.pk_form_wfp3_paymentBMP == PK_Wfp3PaymentBMP) select b; fv.DataKeyNames = new string[] { "pk_form_wfp3_paymentBMP" }; fv.DataSource = a; fv.DataBind(); if (fv.CurrentMode == FormViewMode.Insert) { WACGlobal_Methods.PopulateControl_Custom_Agriculture_BMP_ByWFP3BMP_DDL(fv, "ddlBMP", Convert.ToInt32(FK_Wfp3), null); WACGlobal_Methods.PopulateControl_DatabaseLists_PaymentStatus_DDL(fv.FindControl("ddlPaymentStatus") as DropDownList, null, true); WACGlobal_Methods.PopulateControl_DatabaseLists_AgencyFunding_DDL(fv.FindControl("ddlFundingAgency") as DropDownList, null, "Y", null, true); WACGlobal_Methods.PopulateControl_Custom_Agriculture_WFP3PaymentBMP_ByWFP3Specification_DDL(fv.FindControl("ddlBMPPractice") as DropDownList, Convert.ToInt32(FK_Wfp3), null, true, true); WACGlobal_Methods.PopulateControl_Generic_YesNoDDL(fv, "ddlReimbursementYN", "N", true); } if (fv.CurrentMode == FormViewMode.Edit) { decimal?bmp = a.Any() ? a.Single().fk_bmpPractice_code : null; WACGlobal_Methods.PopulateControl_DatabaseLists_PaymentStatus_DDL(fv.FindControl("ddlPaymentStatus") as DropDownList, a.Single().fk_paymentStatus_code, true); WACGlobal_Methods.PopulateControl_DatabaseLists_AgencyFunding_DDL(fv.FindControl("ddlFundingAgency") as DropDownList, null, "Y", a.Single().fk_agencyFunding_code, true); //WACGlobal_Methods.PopulateControl_Custom_Agriculture_WFP3PaymentBMP_ByWFP3Specification_DDL(fv.FindControl("ddlBMPPractice") as DropDownList, Convert.ToInt32(FK_Wfp3), null, true, true); //WACGlobal_Methods.PopulateControl_Custom_Agriculture_WFP3PaymentBMP_ByWFP3Specification_DDL(fv.FindControl("ddlBMPPractice") as DropDownList, Convert.ToInt32(FK_Wfp3), a.Single().fk_bmpPractice_code, true, true); WACGlobal_Methods.PopulateControl_DatabaseLists_BMPPractice_DDL((DropDownList)fv.FindControl("ddlBMPPractice"), bmp, true, true, false); DropDownList ddlReimbursementYN = fv.FindControl("ddlReimbursementYN") as DropDownList; WACGlobal_Methods.PopulateControl_Generic_YesNoDDL(fv.FindControl("ddlReimbursementYN") as DropDownList, a.Single().reimbursement, true); } } }