protected void gvPreventLocationsList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { decimal plantId = (decimal)gvPreventLocationsList.DataKeys[e.Row.RowIndex].Value; RadGrid rg = (RadGrid)e.Row.FindControl("rgPlantContacts"); var personList = EHSIncidentMgr.SelectEhsPeopleAtPlant(plantId); if (personList.Count > 0) { rg.DataSource = personList; rg.DataBind(); if (IsEditContext == true) { // Find and select people previously selected PSsqmEntities entities = new PSsqmEntities(); foreach (GridDataItem dataItem in rg.Items) { decimal personId = (decimal)dataItem.GetDataKeyValue("PERSON_ID"); if (personId != null) { var verificationLine = (from iv in entities.INCIDENT_VERIFICATION where iv.INCIDENT_ID == IncidentId && iv.PLANT_ID == plantId && iv.PERSON_ID == personId select iv).FirstOrDefault(); if (verificationLine != null) { dataItem.Selected = true; if (verificationLine.HAS_RESPONDED == true) { Label confirmedLabel = (Label)dataItem.FindControl("lblConfirmed"); confirmedLabel.Visible = true; } } } } } } else { e.Row.Visible = false; } var comments = EHSIncidentMgr.SelectIncidentComments(IncidentId, plantId); Panel pc = (Panel)e.Row.FindControl("pnlComments"); RadGrid rgc = (RadGrid)e.Row.FindControl("rgPlantComments"); if (comments.Count > 0) { pc.Visible = true; rgc.DataSource = comments; rgc.DataBind(); } } }