public override void Validate()
        {
            // Validate page
            base.Validate();

            if (Page.IsValid)
            {
                // Update flatSectionJlineTDS
                foreach (GridViewRow row in grdvJliner.Rows)
                {
                    // ... Get standard fields
                    Guid id = new Guid(((HiddenField)row.FindControl("hdfId")).Value);
                    int companyId = int.Parse(((HiddenField)row.FindControl("hdfCompanyId")).Value);
                    double? distanceFromUSMH = null; if (((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim() != "") distanceFromUSMH = double.Parse(((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim());

                    // ... Calculate fields
                    double? distanceFromDSMH = null;
                    if (distanceFromUSMH.HasValue)
                    {
                        SectionGateway sectionGateway = new SectionGateway();
                        sectionGateway.LoadById(id, companyId);

                        Distance length = new Distance(sectionGateway.GetActualLength(id)) - new Distance(((double)distanceFromUSMH).ToString());
                        distanceFromDSMH = length.ToDoubleInEng3();
                    }

                    // ... Check validation fields
                    if (distanceFromDSMH.HasValue)
                    {
                        if ((double)distanceFromDSMH < 0)
                        {
                            CompareValidator cvDistanceFromDSMH = ((CompareValidator)row.FindControl("cvDistanceFromDSMH"));
                            cvDistanceFromDSMH.IsValid = false;
                        }
                    }
                }
            }
        }
        private void Save2()
        {
            Page.Validate();

            if (Page.IsValid)
            {
                FlatSectionJliner flatSectionJliner = new FlatSectionJliner(flatSectionJlinerTDS);

                // Update flatSectionJlinerTDS
                foreach (GridViewRow row in grdvJliner.Rows)
                {
                    // ... Get standard fields
                    Guid id = new Guid(((HiddenField)row.FindControl("hdfId")).Value);
                    int companyId = int.Parse(((HiddenField)row.FindControl("hdfCompanyId")).Value);
                    int refId = int.Parse(((HiddenField)row.FindControl("hdfRefId")).Value);
                    string recordId = ((HiddenField)row.FindControl("hdfRecordId")).Value;
                    string detailId = ((HiddenField)row.FindControl("hdfDetailId")).Value;
                    string id_ = ((TextBox)row.FindControl("tbxId_")).Text.Trim();
                    string address = ((TextBox)row.FindControl("tbxAddress")).Text.Trim();
                    DateTime? pipeLocated = null; if (((TextBox)row.FindControl("tbxPipeLocated")).Text.Trim() != "") pipeLocated = DateTime.Parse(((TextBox)row.FindControl("tbxPipeLocated")).Text.Trim());
                    DateTime? servicesLocated = null; if (((TextBox)row.FindControl("tbxServicesLocated")).Text.Trim() != "") servicesLocated = DateTime.Parse(((TextBox)row.FindControl("tbxServicesLocated")).Text.Trim());
                    DateTime? coInstalled = null; if (((TextBox)row.FindControl("tbxCoInstalled")).Text.Trim() != "") coInstalled = DateTime.Parse(((TextBox)row.FindControl("tbxCoInstalled")).Text.Trim());
                    DateTime? backfilledConcrete = null; if (((TextBox)row.FindControl("tbxBackfilledConcrete")).Text.Trim() != "") backfilledConcrete = DateTime.Parse(((TextBox)row.FindControl("tbxBackfilledConcrete")).Text.Trim());
                    DateTime? backfilledSoil = null; if (((TextBox)row.FindControl("tbxBackfilledSoil")).Text.Trim() != "") backfilledSoil = DateTime.Parse(((TextBox)row.FindControl("tbxBackfilledSoil")).Text.Trim());
                    DateTime? grouted = null; if (((TextBox)row.FindControl("tbxGrouted")).Text.Trim() != "") grouted = DateTime.Parse(((TextBox)row.FindControl("tbxGrouted")).Text.Trim());
                    DateTime? cored = null; if (((TextBox)row.FindControl("tbxCored")).Text.Trim() != "") cored = DateTime.Parse(((TextBox)row.FindControl("tbxCored")).Text.Trim());
                    DateTime? prepped = null; if (((TextBox)row.FindControl("tbxPrepped")).Text.Trim() != "") prepped = DateTime.Parse(((TextBox)row.FindControl("tbxPrepped")).Text.Trim());
                    DateTime? measured = null; if (((TextBox)row.FindControl("tbxMeasured")).Text.Trim() != "") measured = DateTime.Parse(((TextBox)row.FindControl("tbxMeasured")).Text.Trim());
                    string linerSize = ""; if (((TextBox)row.FindControl("tbxLinerSize")).Text.Trim() != "") linerSize = ((TextBox)row.FindControl("tbxLinerSize")).Text.Trim();
                    bool liningThruCo = ((CheckBox)row.FindControl("cbxLiningThruCo")).Checked;
                    DateTime? inProcess = null; if (((TextBox)row.FindControl("tbxInProcess")).Text.Trim() != "") inProcess = DateTime.Parse(((TextBox)row.FindControl("tbxInProcess")).Text.Trim());
                    DateTime? inStock = null; if (((TextBox)row.FindControl("tbxInStock")).Text.Trim() != "") inStock = DateTime.Parse(((TextBox)row.FindControl("tbxInStock")).Text.Trim());
                    DateTime? delivered = null; if (((TextBox)row.FindControl("tbxDelivered")).Text.Trim() != "") delivered = DateTime.Parse(((TextBox)row.FindControl("tbxDelivered")).Text.Trim());
                    DateTime? preVideo = null; if (((TextBox)row.FindControl("tbxPreVideo")).Text.Trim() != "") preVideo = DateTime.Parse(((TextBox)row.FindControl("tbxPreVideo")).Text.Trim());
                    DateTime? linerInstalled = null; if (((TextBox)row.FindControl("tbxLinerInstalled")).Text.Trim() != "") linerInstalled = DateTime.Parse(((TextBox)row.FindControl("tbxLinerInstalled")).Text.Trim());
                    DateTime? finalVideo = null; if (((TextBox)row.FindControl("tbxFinalVideo")).Text.Trim() != "") finalVideo = DateTime.Parse(((TextBox)row.FindControl("tbxFinalVideo")).Text.Trim());
                    double? distanceFromUSMH = null; if (((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim() != "") distanceFromUSMH = double.Parse(((TextBox)row.FindControl("tbxDistanceFromUSMH")).Text.Trim());
                    string comments = ""; if (((TextBox)row.FindControl("tbxComments")).Text.Trim() != "") comments = ((TextBox)row.FindControl("tbxComments")).Text.Trim();
                    string history = ""; if (((TextBox)row.FindControl("tbxHistory")).Text.Trim() != "") history = ((TextBox)row.FindControl("tbxHistory")).Text.Trim();
                    string issue = ((DropDownList)row.FindControl("ddlIssue")).SelectedValue.Trim();
                    decimal? cost = null; if (((TextBox)row.FindControl("tbxCost")).Text.Trim() != "") cost = decimal.Parse(((TextBox)row.FindControl("tbxCost")).Text.Trim());
                    bool deleted = false;
                    bool selected = true;
                    DateTime? videoInspection = null; if (((TextBox)row.FindControl("tbxVideoInspection")).Text.Trim() != "") videoInspection = DateTime.Parse(((TextBox)row.FindControl("tbxVideoInspection")).Text.Trim());
                    string videoLengthToPropertyLine = ""; if (((TextBox)row.FindControl("tbxVideoLengthToPropertyLine")).Text.Trim() != "") videoLengthToPropertyLine = ((TextBox)row.FindControl("tbxVideoLengthToPropertyLine")).Text.Trim();
                    bool coRequired = ((CheckBox)row.FindControl("cbxCoReq")).Checked;
                    bool pitRequired = ((CheckBox)row.FindControl("cbxPitReq")).Checked;
                    string coPitLocation = ""; coPitLocation = ((DropDownList)row.FindControl("ddlCoPitLocation")).SelectedValue;
                    bool postContractDigRequired = ((CheckBox)row.FindControl("cbxPostContractDigRequired")).Checked;
                    DateTime? coCutDown = null; if (((TextBox)row.FindControl("tbxCoCutDown")).Text.Trim() != "") coCutDown = DateTime.Parse(((TextBox)row.FindControl("tbxCoCutDown")).Text.Trim());
                    DateTime? finalRestoration = null; if (((TextBox)row.FindControl("tbxFinalRestoration")).Text.Trim() != "") finalRestoration = DateTime.Parse(((TextBox)row.FindControl("tbxFinalRestoration")).Text.Trim());
                    string clientLateralId = ""; if (((TextBox)row.FindControl("tbxClientLateralId")).Text.Trim() != "") clientLateralId = ((TextBox)row.FindControl("tbxClientLateralId")).Text.Trim();
                    string hamiltonInspectionNumber = ""; if (((TextBox)row.FindControl("tbxHamiltonInspectionNumber")).Text.Trim() != "") hamiltonInspectionNumber = ((TextBox)row.FindControl("tbxHamiltonInspectionNumber")).Text.Trim();
                    DateTime? noticeDelivered = null; if (((TextBox)row.FindControl("tbxNoticeDelivered")).Text.Trim() != "") noticeDelivered = DateTime.Parse(((TextBox)row.FindControl("tbxNoticeDelivered")).Text.Trim());

                    // ... Calculate fields
                    double? distanceFromDSMH = null;
                    if (distanceFromUSMH.HasValue)
                    {
                        SectionGateway sectionGateway = new SectionGateway();
                        sectionGateway.LoadById(id, companyId);

                        Distance length = new Distance(sectionGateway.GetActualLength(id)) - new Distance(((double)distanceFromUSMH).ToString());
                        distanceFromDSMH = length.ToDoubleInEng3();
                    }

                    // ... Update row
                    flatSectionJliner.Update(id_, id, refId, companyId, recordId, detailId, address, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, preVideo, linerInstalled, finalVideo, distanceFromUSMH, distanceFromDSMH, comments, history, issue, cost, deleted, selected, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, clientLateralId, videoLengthToPropertyLine, liningThruCo, hamiltonInspectionNumber, noticeDelivered);
                }

                // Store datasets
                Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS;

                // Update section and jliners
                sectionTDS = new SectionTDS();
                flatSectionJliner.Save(sectionTDS);
            }
        }