protected void grdAddManholeNew_RowDataBound(object sender, GridViewRowEventArgs e) { // Edit controls if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { int companyId = Int32.Parse(hdfCompanyId.Value); int assetId = Int32.Parse(((Label)e.Row.FindControl("lblAssetID")).Text); AddManholeNewGateway addManholeNewGatewayForGrid = new AddManholeNewGateway(addManholeTDS); if (addManholeNewGatewayForGrid.Table.Rows.Count > 0) { ((DropDownList)e.Row.FindControl("ddlShapeEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeShape(assetId); ((DropDownList)e.Row.FindControl("ddlLocationEdit")).SelectedValue = addManholeNewGatewayForGrid.GetLocation(assetId); ((DropDownList)e.Row.FindControl("ddlMaterialEdit")).SelectedValue = addManholeNewGatewayForGrid.GetMaterialID(assetId).ToString(); ((DropDownList)e.Row.FindControl("ddlRehabilitationDataRoundManholeRugsEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeRugs(assetId).ToString(); ((DropDownList)e.Row.FindControl("ddlRehabilitationDataRectangularManholeRugsEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeRugs(assetId).ToString(); ((DropDownList)e.Row.FindControl("ddlRehabilitationDataMixManholeRugsEdit")).SelectedValue = addManholeNewGatewayForGrid.GetManholeRugs(assetId).ToString(); if (addManholeNewGatewayForGrid.GetConditionRating(assetId).HasValue) { ((DropDownList)e.Row.FindControl("ddlConditioningRatingEdit")).SelectedValue = addManholeNewGatewayForGrid.GetConditionRating(assetId).ToString(); } else { ((DropDownList)e.Row.FindControl("ddlConditioningRatingEdit")).SelectedValue = "-1"; } } switch (addManholeNewGatewayForGrid.GetManholeShape(assetId)) { case "Round": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; case "Rectangular": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; case "Mixed": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; case "Other": ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = true; break; default: ((Panel)e.Row.FindControl("pnlInformationRoundMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHEdit")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHEdit")).Visible = false; break; }; } // Normal rows if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { int companyId = Int32.Parse(hdfCompanyId.Value); int assetId = Int32.Parse(((Label)e.Row.FindControl("lblAssetID")).Text); AddManholeNewGateway addManholeNewGatewayForGrid = new AddManholeNewGateway(addManholeTDS); if (addManholeNewGatewayForGrid.Table.Rows.Count > 0) { ((TextBox)e.Row.FindControl("tbxShape")).Text = addManholeNewGatewayForGrid.GetManholeShape(assetId); ((TextBox)e.Row.FindControl("tbxLocation")).Text = addManholeNewGatewayForGrid.GetLocation(assetId); if (addManholeNewGatewayForGrid.GetConditionRating(assetId).HasValue) { ((TextBox)e.Row.FindControl("tbxConditionRating")).Text = addManholeNewGatewayForGrid.GetConditionRating(assetId).ToString(); } else { ((TextBox)e.Row.FindControl("tbxConditionRating")).Text = ""; } int? materialId = addManholeNewGatewayForGrid.GetMaterialID(assetId); ((TextBox)e.Row.FindControl("tbxMaterial")).Text = ""; if (materialId.HasValue) { AssetSewerMHMaterialTypeGateway assetSewerMHMaterialTypeGateway = new AssetSewerMHMaterialTypeGateway(); assetSewerMHMaterialTypeGateway.LoadByMaterialId((int)materialId, companyId); string materialDescription = assetSewerMHMaterialTypeGateway.GetMaterialType((int)materialId); ((TextBox)e.Row.FindControl("tbxMaterial")).Text = materialDescription; } } switch (((TextBox)e.Row.FindControl("tbxShape")).Text) { case "Round": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; case "Rectangular": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; case "Mixed": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; case "Other": ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = true; break; default: ((Panel)e.Row.FindControl("pnlInformationRoundMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMH")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMH")).Visible = false; break; }; } // Footer rows if (e.Row.RowType == DataControlRowType.Footer) { switch (((DropDownList)e.Row.FindControl("ddlShapeAdd")).SelectedValue) { case "Round": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; case "Rectangular": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; case "Mixed": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = true; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; case "Other": ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = true; break; default: ((Panel)e.Row.FindControl("pnlInformationRoundMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationRectangularMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationMixedMHAdd")).Visible = false; ((Panel)e.Row.FindControl("pnlInformationOtherMHAdd")).Visible = false; break; }; //int companyId = Int32.Parse(hdfCompanyId.Value); //string lastShape = ""; //// ... load last shape used at the grid //foreach (GridViewRow row in grdAddManholeNew.Rows) //{ // lastShape = ((TextBox)row.FindControl("tbxShape")).Text; //} //if (lastShape != "") //{ // ((DropDownList)e.Row.FindControl("ddlShapeAdd")).SelectedValue = lastShape; //} //else //{ // ((DropDownList)e.Row.FindControl("ddlShapeAdd")).SelectedIndex = 0; //} } }