protected void cvUsmhDsmhDBEdit_ServerValidate(object source, ServerValidateEventArgs args)
        {
            // Initialize
            args.IsValid = true;

            // Validate if mh already exists
            int companyId = Int32.Parse(hdfCompanyId.Value);
            Int64? countryId = null; if (hdfCountryId.Value != "0") countryId = Int64.Parse(hdfCountryId.Value);
            Int64? provinceId = null; if (hdfProvinceId.Value != "0") provinceId = Int64.Parse(hdfProvinceId.Value);
            Int64? countyId = null; if (hdfCountyId.Value != "0") countyId = Int64.Parse(hdfCountyId.Value);
            Int64? cityId = null; if (hdfCityId.Value != "0") cityId = Int64.Parse(hdfCityId.Value);
            int projectId = int.Parse(hdfProjectId.Value);

            CustomValidator cvUsmhDsmhDBEdit = (CustomValidator)source;
            GridViewRow gridRow = (GridViewRow)cvUsmhDsmhDBEdit.NamingContainer;

            string usmh = ((TextBox)gridRow.FindControl("tbxUsmhEdit")).Text;
            string dsmh = ((TextBox)gridRow.FindControl("tbxDsmhEdit")).Text;

            AssetSewerMHGateway assetSewerMhGatewayUSMH = new AssetSewerMHGateway();
            assetSewerMhGatewayUSMH.LoadByCountryIdProvinceIdCountyIdCityIdMhId(countryId, provinceId, countyId, cityId, usmh, companyId, "", "", "");//TODO MH

            AssetSewerMHGateway assetSewerMhGatewayDSMH = new AssetSewerMHGateway();
            assetSewerMhGatewayDSMH.LoadByCountryIdProvinceIdCountyIdCityIdMhId(countryId, provinceId, countyId, cityId, dsmh, companyId, "", "", "");//TODO MH

            if (assetSewerMhGatewayUSMH.Table.Rows.Count > 0 && assetSewerMhGatewayDSMH.Table.Rows.Count > 0)
            {
                int assetIdUsmh = assetSewerMhGatewayUSMH.GetAssetID(usmh);
                int assetIdDsmh = assetSewerMhGatewayDSMH.GetAssetID(dsmh);

                AssetSewerMHGateway assetSewerMhGateway = new AssetSewerMHGateway(null);
                if (assetSewerMhGateway.USmhDsmhInUseForSections(assetIdUsmh, assetIdDsmh, companyId))
                {
                    args.IsValid = false;
                }
            }
        }
        protected void cvUsmhDsmhDBAdd_ServerValidate(object source, ServerValidateEventArgs args)
        {
            bool usmhAndDsmhValid = true;
            args.IsValid = true;

            // Validate if mh already exists
            int companyId = Int32.Parse(hdfCompanyId.Value);
            Int64? countryId = null; if (hdfCountryId.Value != "0") countryId = Int64.Parse(hdfCountryId.Value);
            Int64? provinceId = null; if (hdfProvinceId.Value != "0") provinceId = Int64.Parse(hdfProvinceId.Value);
            Int64? countyId = null; if (hdfCountyId.Value != "0") countyId = Int64.Parse(hdfCountyId.Value);
            Int64? cityId = null; if (hdfCityId.Value != "0") cityId = Int64.Parse(hdfCityId.Value);
            int projectId = int.Parse(hdfProjectId.Value);

            string usmh = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxUsmhAdd")).Text;
            string dsmh = ((TextBox)grdProjectAddSectionsNew.FooterRow.FindControl("tbxDsmhAdd")).Text;

            AssetSewerMHGateway assetSewerMhGatewayUSMH = new AssetSewerMHGateway();
            assetSewerMhGatewayUSMH.LoadByCountryIdProvinceIdCountyIdCityIdMhId(countryId, provinceId, countyId, cityId, usmh, companyId, "", "", "");// TODO MH

            AssetSewerMHGateway assetSewerMhGatewayDSMH = new AssetSewerMHGateway();
            assetSewerMhGatewayDSMH.LoadByCountryIdProvinceIdCountyIdCityIdMhId(countryId, provinceId, countyId, cityId, dsmh, companyId, "", "", ""); // TODO MH

            if (assetSewerMhGatewayUSMH.Table.Rows.Count > 0 && assetSewerMhGatewayDSMH.Table.Rows.Count > 0)
            {
                int assetIdUsmh = assetSewerMhGatewayUSMH.GetAssetID(usmh);
                int assetIdDsmh = assetSewerMhGatewayDSMH.GetAssetID(dsmh);

                AssetSewerMHGateway assetSewerMhGateway = new AssetSewerMHGateway(null);
                if (assetSewerMhGateway.USmhDsmhInUseForSections(assetIdUsmh, assetIdDsmh, companyId))
                {
                    usmhAndDsmhValid = false;
                }
            }

            if (usmhAndDsmhValid)
            {
                foreach (GridViewRow row in grdProjectAddSectionsNew.Rows)
                {
                    string usmhRow = ((TextBox)row.FindControl("tbxUsmh")).Text;
                    string dsmhRow = ((TextBox)row.FindControl("tbxDsmh")).Text;

                    if ((usmhRow == usmh && dsmhRow == dsmh) || (usmhRow == dsmh && dsmhRow == usmh))
                    {
                        usmhAndDsmhValid = false;
                    }
                }
            }

            args.IsValid = usmhAndDsmhValid;
        }