private void BindData_BMPPlanning_FormView(decimal iPK_BMP_AG) { using (WACDataClassesDataContext wac = new WACDataClassesDataContext()) { var a = wac.bmp_ags.Where(w => w.pk_bmp_ag == iPK_BMP_AG).Select(s => new { s.pk_bmp_ag, s.fk_farmBusiness, s.bmp_nbr, s.fk_BMPSource_code, s.list_BMPSource, s.location, s.description, s.list_statusBMP, s.fk_pollutant_category_code, s.list_pollutant_category, s.fk_bmpPractice_code, s.list_bmpPractice, s.fk_revisionDescription_code, s.list_revisionDescription, s.units_planned, s.fk_unit_code, s.est_plan_prior, s.est_plan_rev, s.CREP, s.fk_SAAssignType_code, s.list_SAAssignType, s.fk_supplementalAgreementTaxParcel, s.supplementalAgreementTaxParcel, s.issueStatement_wfp2, FARMID = s.farmBusiness.farmID, FARMNAME = s.farmBusiness.farm_name, FARMOWNER = s.farmBusiness.ownerStr_dnd, s.created, s.created_by, s.modified, s.modified_by }); fvBMPPlanning.DataKeyNames = new string[] { "pk_bmp_ag" }; fvBMPPlanning.DataSource = a; fvBMPPlanning.DataBind(); if (fvBMPPlanning.CurrentMode == FormViewMode.ReadOnly && a.Count() == 1) { WACGlobal_Methods.PopulateControl_DatabaseLists_Year_DDL(fvBMPPlanning.FindControl("ddlBMPPlanning_ImplementationYears_Insert") as DropDownList, null); } if (fvBMPPlanning.CurrentMode == FormViewMode.Insert) { WACGlobal_Methods.PopulateControl_Custom_Agriculture_Farm_DDL(fvBMPPlanning.FindControl("ddlFarm") as DropDownList, null, false, true, true); WACGlobal_Methods.PopulateControl_DatabaseLists_BMPSource_DDL(fvBMPPlanning, "ddlBMPSource", "N", false); WACGlobal_Methods.PopulateControl_DatabaseLists_RevisionDescription_DDL(fvBMPPlanning, "ddlRevisionDescription", null, null); WACGlobal_Methods.PopulateControl_DatabaseLists_PollutantCategory_DDL(fvBMPPlanning.FindControl("ddlPollutantCategory") as DropDownList, null, false, true); WACGlobal_Methods.PopulateControl_DatabaseLists_BMPPractice_DDL(fvBMPPlanning.FindControl("ddlBMPPractice") as DropDownList, null, true, true, false); WACGlobal_Methods.PopulateControl_DatabaseLists_Year_DDL(fvBMPPlanning.FindControl("ddlImplementationYear") as DropDownList, DateTime.Now.Year); WACGlobal_Methods.PopulateControl_DatabaseLists_SupplementalAgreementAssignment_DDL(fvBMPPlanning.FindControl("ddlSAA") as DropDownList, null, true); WACGlobal_Methods.PopulateControl_Generic_YesNoDDL(fvBMPPlanning.FindControl("ddlCREP") as DropDownList, "N", true); WACGlobal_Methods.PopulateControl_DatabaseLists_NMCPType_DDL(fvBMPPlanning, "ddlNMCPType", null, true); HandleSupplementalAgreementsBasedOnFarm(null); } if (fvBMPPlanning.CurrentMode == FormViewMode.Edit) { WACGlobal_Methods.PopulateControl_DatabaseLists_BMPSource_DDL(fvBMPPlanning, "ddlBMPSource", a.Single().fk_BMPSource_code, false); WACGlobal_Methods.PopulateControl_DatabaseLists_RevisionDescription_DDL(fvBMPPlanning, "ddlRevisionDescription", a.Single().fk_revisionDescription_code, a.Single().list_revisionDescription.active); WACGlobal_Methods.PopulateControl_DatabaseLists_PollutantCategory_DDL(fvBMPPlanning.FindControl("ddlPollutantCategory") as DropDownList, a.Single().fk_pollutant_category_code, false, false); WACGlobal_Methods.PopulateControl_DatabaseLists_BMPPractice_DDL(fvBMPPlanning.FindControl("ddlBMPPractice") as DropDownList, a.Single().fk_bmpPractice_code, true, false, false); WACGlobal_Methods.PopulateControl_DatabaseLists_SupplementalAgreementAssignment_DDL(fvBMPPlanning.FindControl("ddlSAA") as DropDownList, a.Single().fk_SAAssignType_code, true); WACGlobal_Methods.PopulateControl_Generic_YesNoDDL(fvBMPPlanning.FindControl("ddlCREP") as DropDownList, a.Single().CREP, true); //WACGlobal_Methods.PopulateControl_DatabaseLists_NMCPType_DDL(fvBMPPlanning, "ddlNMCPType", a.Single().fk_NMCPType_code, true); HandleSupplementalAgreementsBasedOnFarm(a.Single().fk_supplementalAgreementTaxParcel); DropDownList ddlPractice = fvBMPPlanning.FindControl("ddlBMPPractice") as DropDownList; Label lblUnits = fvBMPPlanning.FindControl("lblUnits") as Label; if (!string.IsNullOrEmpty(ddlPractice.SelectedValue)) { lblUnits.Text = WACGlobal_Methods.SpecialQuery_Agriculture_Unit_By_BMPPractice(ddlPractice.SelectedValue); } } } }