protected void grdLaterals_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate))))
            {
                int lateral = int.Parse(((Label)e.Row.FindControl("lblLateral")).Text);

                if (lateral > 0)
                {
                    FullLengthLiningLateralDetailsGateway gateway = new FullLengthLiningLateralDetailsGateway(fullLengthLiningTDS);
                    ((TextBox)e.Row.FindControl("tbxMaterial")).Text = gateway.GetMaterialType(lateral);
                }
            }

            // Control value for footer material
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                // For Material
                ((DropDownList)e.Row.FindControl("ddlNewMaterial")).SelectedIndex = 0;
            }

            // Control of edit controls
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                int lateral = int.Parse(((Label)e.Row.FindControl("lblLateral")).Text);

                if (lateral > 0)
                {
                    FullLengthLiningLateralDetailsGateway gateway = new FullLengthLiningLateralDetailsGateway(fullLengthLiningTDS);

                    int companyId = Int32.Parse(hdfCompanyId.Value);

                    // ... Control material and connection type dropdownlists
                    ((DropDownList)e.Row.FindControl("ddlMaterialEdit")).SelectedValue = gateway.GetMaterialType(lateral);
                    ((DropDownList)e.Row.FindControl("ddlConnectionTypeEdit")).SelectedValue = gateway.GetConnectionType(lateral);

                    // .... If lateral us used in junction lining
                    if (gateway.GetInJlDatabase(lateral))
                    {
                        if (!LateralsCouldBeDeletedInJl(lateral))
                        {
                            ((CheckBox)e.Row.FindControl("cbxJlEdit")).Enabled = false;
                        }
                    }

                    // ... Control live value
                    int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value);
                    WorkGateway workGateway = new WorkGateway();
                    workGateway.LoadByProjectIdAssetIdWorkType(currentProjectId, lateral, "Junction Lining Lateral", companyId);

                    // ... If lateral is not used in junction lining
                    if (!workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(lateral, currentProjectId, "Junction Lining Lateral", companyId))
                    {
                        ((DropDownList)e.Row.FindControl("ddlLiveEdit")).Visible = true;
                        ((DropDownList)e.Row.FindControl("ddlLiveEdit")).SelectedValue = gateway.GetLive(lateral);
                        ((TextBox)e.Row.FindControl("tbxJlLive")).Visible = false;
                    }
                    else
                    {
                        ((DropDownList)e.Row.FindControl("ddlLiveEdit")).Visible = false;
                        ((TextBox)e.Row.FindControl("tbxJlLive")).Visible = true;
                    }
                }
            }
        }
        /// <summary>
        /// Update Lateral
        /// </summary>
        /// <param name="row">row</param>
        /// <param name="projectId">projectId</param>
        /// <param name="sectionAssetId">sectionAssetId</param>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="videoLength">videoLength</param>
        /// <param name="companyId">companyId</param>
        private void UpdateLateral(FullLengthLiningTDS.LateralDetailsRow row, int projectId, int sectionAssetId, Int64 countryId, Int64? provinceId, Int64? countyId, Int64? cityId, string videoLength, int companyId)
        {
            // not modified variables
            FullLengthLiningTDS fullLengthLining = (FullLengthLiningTDS)Data;
            FullLengthLiningLateralDetailsGateway fullLengthLiningLateralDetailsGateway = new FullLengthLiningLateralDetailsGateway(fullLengthLining);
            int lateral = row.Lateral;

            AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway();
            assetSewerLateralGateway.LoadByAssetId(lateral, companyId);

            int section_ = assetSewerLateralGateway.GetSection(lateral);
            string address = assetSewerLateralGateway.GetAddress(lateral);
            string lateralId = assetSewerLateralGateway.GetLateralId(lateral);
            string latitudeAtSection = assetSewerLateralGateway.GetLatitudeAtSection(lateral);
            string longitudeAtSection = assetSewerLateralGateway.GetLongitudeAtSection(lateral);
            string latitudeAtPropertyLine = assetSewerLateralGateway.GetLatitudeAtPropertyLine(lateral);
            string longitudeAtPropertyLine = assetSewerLateralGateway.GetLongitudeAtPropertyLine(lateral);
            string mapSize = assetSewerLateralGateway.GetMapSize(lateral);

            // original values
            string originalState = fullLengthLiningLateralDetailsGateway.GetLiveOriginal(lateral);
            string originalSize = fullLengthLiningLateralDetailsGateway.GetSizeOriginal(lateral);
            string originalDistanceFromUsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromUSMHOriginal(lateral);
            string originalDistanceFromDsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromDSMHOriginal(lateral);
            string originalConnectionType = fullLengthLiningLateralDetailsGateway.GetConnectionTypeOriginal(lateral);
            string originalAddress = fullLengthLiningLateralDetailsGateway.GetMnOriginal(lateral);

            // new values
            string newState = fullLengthLiningLateralDetailsGateway.GetLive(lateral);
            string newSize = fullLengthLiningLateralDetailsGateway.GetSize(lateral);
            string newDistanceFromUsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromUSMH(lateral);
            string newDistanceFromDsmh = fullLengthLiningLateralDetailsGateway.GetDistanceFromDSMH(lateral);
            string newConnectionType = fullLengthLiningLateralDetailsGateway.GetConnectionType(lateral);
            string newAddress = fullLengthLiningLateralDetailsGateway.GetMn(lateral);

            // update asset laterals
            AssetSewerLateral assetSewerLateral = new AssetSewerLateral(null);
            assetSewerLateral.UpdateDirect(lateral, section_, originalAddress, lateralId, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, originalState, originalSize, originalDistanceFromUsmh, originalDistanceFromDsmh, mapSize, false, companyId, originalConnectionType, lateral, section_, newAddress, lateralId, latitudeAtSection, longitudeAtSection, latitudeAtPropertyLine, longitudeAtPropertyLine, newState, newSize, newDistanceFromUsmh, newDistanceFromDsmh, mapSize, false, companyId, newConnectionType);
        }