protected void reportGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (!(e.Item is GridDataItem)) return;

            // Assign local variables for common Assessment Data values.
            var dataItem = (DataRowView) (e.Item).DataItem;
            var QuestionType = dataItem["QuestionType"].ToString();
            var correctAnswer = dataItem["CorrectAnswer"].ToString();
            var isFieldTest = dataItem["FieldTest"].ToString() == "1";
			var scoreType = dataItem["ScoreType"].ToString();
            var ChartGroup = dataItem["ChartGroup"].ToString();
            var itemID = dataItem["xID"].ToString();
            var rubricSort = dataItem["TR_Sort"].ToString();

            // Assign local variables for commonly referred to columns
            const int indexMultChoiceA = 5; //The index of the A column
            const int itemNumberCellIndex = 1; //
            var green = Color.GreenYellow;
            var yellow = Color.Yellow;
            var itemLinks = (Label)e.Item.FindControl("itemLinks");

            // TFS 1123: Disable item preview link for Teacher and School Admin login if assessment content is locked
            ReportHelper reportHelper = new ReportHelper();
            reportHelper.UserRoles = SessionObject.LoggedInUser.Roles;
            if (_isContentLocked && reportHelper.DisableItemLinks())
                itemLinks.Text = ChartGroup;
            else
                itemLinks.Text = "<a href=\"javascript:void(0);\" onclick=\"openItemPreview('../ControlHost/PreviewTestQuestion.aspx?xID=" +
                    itemID + "'); return false;\">" + ChartGroup + "</a>";

            /**************************************************************************
            * Display all field test questions with a yellow background.
            **************************************************************************/
            if (isFieldTest)
            {
                e.Item.Cells[itemNumberCellIndex].BackColor = yellow;
            }


            /***************************************************************************
            * For all other distractors that are not part of the test question, blank 
            * these out.  We wouldn't want them to "distract" the user from clearly
            * regarding the test question's answers.
            **************************************************************************/
            if (QuestionType != "MC4" && QuestionType != "MC3" && QuestionType != "MC5") foreach (var i in colAryMC) e.Item.Cells[i + 2].Text = "-";

            if (QuestionType != "T") foreach (var i in colAryTF) e.Item.Cells[i + 2].Text = "-";

			if (scoreType != "W") foreach (var i in colAryRW) e.Item.Cells[i + 2].Text = "-";

            if (scoreType == "R" && rubricSort == "0")
            {
                foreach (var i in colAryRubric)
                {
                    if (i != colIdxRubricType)
                        e.Item.Cells[i + 2].Text = "-";
                }

                foreach (var i in colAryUnanswered)
                    e.Item.Cells[i + 2].Text = "-";
            }

			if (scoreType == "W") foreach (var i in colAryRubric) e.Item.Cells[i + 2].Text = "-";

            /**************************************************************************
             * Highlight cell with correct answer
             *************************************************************************/
            switch (QuestionType)
            {
                case "MC5": // Multiple Choice
                    switch (correctAnswer)
                    {
                        case "A":
                            e.Item.Cells[indexMultChoiceA].BackColor = green;
                            break;

                        case "B":
                            e.Item.Cells[indexMultChoiceA + 1].BackColor = green;
                            break;

                        case "C":
                            e.Item.Cells[indexMultChoiceA + 2].BackColor = green;
                            break;

                        case "D":
                            e.Item.Cells[indexMultChoiceA + 3].BackColor = green;
                            break;

                        case "E":
                            e.Item.Cells[indexMultChoiceA + 4].BackColor = green;
                            break;

                    }
                    break;

                case "MC4": // Multiple Choice
                    switch (correctAnswer)
                    {
                        case "A":
                            e.Item.Cells[indexMultChoiceA].BackColor = green;
                            break;

                        case "B":
                            e.Item.Cells[indexMultChoiceA + 1].BackColor = green;
                            break;

                        case "C":
                            e.Item.Cells[indexMultChoiceA + 2].BackColor = green;
                            break;

                        case "D":
                            e.Item.Cells[indexMultChoiceA + 3].BackColor = green;
                            break;

                    }
                    break;

                case "MC3": // Multiple Choice
                    switch (correctAnswer)
                    {
                        case "A":
                            e.Item.Cells[indexMultChoiceA].BackColor = green;
                            break;

                        case "B":
                            e.Item.Cells[indexMultChoiceA + 1].BackColor = green;
                            break;

                        case "C":
                            e.Item.Cells[indexMultChoiceA + 2].BackColor = green;
                            break;
                    }
                    break;

                case "T":  //True or False
                    switch (correctAnswer)
                    {
                        case "A":
                            e.Item.Cells[colIdxTrue + 2].BackColor = green;
                            break;

                        case "B":
                            e.Item.Cells[colIdxTrue + 3].BackColor = green;
                            break;
                    }
                    break;

                /* At this point, there is no "Correct Answer" for Short Answer or Essay type questions - probably because partial credit is regarded with these. */
                //case "S":  //Short Answer
                //    break;

                //case "E":  //Essay
                //    break;
            }

            /***************************************************************************
             * If test question has a distractor rationale, then answer columns for the
             * test question should be hyperlinks that will display a pie chart break
             * down of the answers chosen.
             * 
             * Until we get this working ht, let's just test it on Answer A
             **************************************************************************/
            string pieChartLink;
            if (dataItem["DistractorRationale"].ToString() != "" && QuestionType != "E" && QuestionType != "S")
            {
                pieChartLink = displayCountAsPieChartAnchor(dataItem);

                //e.Item.Cells[colIdxA + 2].Text = displayCountAsPieChartAnchor(dataItem);
                switch (QuestionType)
                {
                    case "MC5":

                        //When used to locate the right cells within the Item Databound event, we 
                        //must add two to our column names.
                        e.Item.Cells[colIdxA + 2].Text = pieChartLink.Replace("{*value*}", dataItem["AFreq#"].ToString());
                        e.Item.Cells[colIdxB + 2].Text = pieChartLink.Replace("{*value*}", dataItem["BFreq#"].ToString());
                        e.Item.Cells[colIdxC + 2].Text = pieChartLink.Replace("{*value*}", dataItem["CFreq#"].ToString());
                        e.Item.Cells[colIdxD + 2].Text = pieChartLink.Replace("{*value*}", dataItem["DFreq#"].ToString());
                        e.Item.Cells[colIdxE + 2].Text = pieChartLink.Replace("{*value*}", dataItem["EFreq#"].ToString());
                        e.Item.Cells[colIdxRight + 2].Text = pieChartLink.Replace("{*value*}", dataItem["RFreq#"].ToString());
                        e.Item.Cells[colIdxWrong + 2].Text = pieChartLink.Replace("{*value*}", dataItem["WFreq#"].ToString());
                        break;

                    case "MC4":

                        //When used to locate the right cells within the Item Databound event, we 
                        //must add two to our column names.
                        e.Item.Cells[colIdxA + 2].Text = pieChartLink.Replace("{*value*}", dataItem["AFreq#"].ToString());
                        e.Item.Cells[colIdxB + 2].Text = pieChartLink.Replace("{*value*}", dataItem["BFreq#"].ToString());
                        e.Item.Cells[colIdxC + 2].Text = pieChartLink.Replace("{*value*}", dataItem["CFreq#"].ToString());
                        e.Item.Cells[colIdxD + 2].Text = pieChartLink.Replace("{*value*}", dataItem["DFreq#"].ToString());
                        e.Item.Cells[colIdxRight + 2].Text = pieChartLink.Replace("{*value*}", dataItem["RFreq#"].ToString());
                        e.Item.Cells[colIdxWrong + 2].Text = pieChartLink.Replace("{*value*}", dataItem["WFreq#"].ToString());
                        break;


                    case "MC3":

                        //When used to locate the right cells within the Item Databound event, we 
                        //must add two to our column names.
                        e.Item.Cells[colIdxA + 2].Text = pieChartLink.Replace("{*value*}", dataItem["AFreq#"].ToString());
                        e.Item.Cells[colIdxB + 2].Text = pieChartLink.Replace("{*value*}", dataItem["BFreq#"].ToString());
                        e.Item.Cells[colIdxC + 2].Text = pieChartLink.Replace("{*value*}", dataItem["CFreq#"].ToString());
                        e.Item.Cells[colIdxRight + 2].Text = pieChartLink.Replace("{*value*}", dataItem["RFreq#"].ToString());
                        e.Item.Cells[colIdxWrong + 2].Text = pieChartLink.Replace("{*value*}", dataItem["WFreq#"].ToString());
                        break;

                    case "T":
                        e.Item.Cells[colIdxTrue + 2].Text = pieChartLink.Replace("{*value*}", dataItem["TFreq#"].ToString());
                        e.Item.Cells[colIdxFalse + 2].Text = pieChartLink.Replace("{*value*}", dataItem["FFreq#"].ToString());
                        e.Item.Cells[colIdxRight + 2].Text = pieChartLink.Replace("{*value*}", dataItem["RFreq#"].ToString());
                        e.Item.Cells[colIdxWrong + 2].Text = pieChartLink.Replace("{*value*}", dataItem["WFreq#"].ToString());
                        e.Item.Cells[colIdxRight + 2].Text = pieChartLink.Replace("{*value*}", dataItem["RFreq#"].ToString());
                        e.Item.Cells[colIdxWrong + 2].Text = pieChartLink.Replace("{*value*}", dataItem["WFreq#"].ToString());
                        break;

                    case "S":
                    case "E":
                        e.Item.Cells[colIdxRight + 2].Text = pieChartLink.Replace("{*value*}", dataItem["RFreq#"].ToString());
                        e.Item.Cells[colIdxWrong + 2].Text = pieChartLink.Replace("{*value*}", dataItem["WFreq#"].ToString());
                        break;
                }
            }
        }
        protected void reportGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (!(e.Item is GridDataItem))
                {
                    if (e.Item.ItemIndex == -1)
                    {
                        GridItem[] header = reportGrid.MasterTableView.GetItems(GridItemType.Header);
                        GridHeaderItem headerItem = (GridHeaderItem)header[0];

                        LinkButton headerNameLink = (LinkButton)headerItem["Name"].Controls[0];
                        headerItem["Name"].Attributes["style"] = "cursor:pointer;"
                                                                 +
                                                                 (_selectedSortColumn == "Name"
                                                                      ? "background: url(../Images/" +
                                                                        (_selectedSortMethod == "DESC"
                                                                             ? "uparrow.gif"
                                                                             : "downarrow.gif") +
                                                                        ") no-repeat right center;"
                                                                      : "");
                        if (_selectedSortColumn == "Name") headerItem["Name"].Attributes["selectedSortColumn"] = "true";
                        else headerItem["Name"].Attributes["selectedSortColumn"] = "false";
                        headerItem["Name"].Attributes["onclick"] = "sortRadGridWithCustomHeaderLinks_OnClick(this, event);";
                        headerItem["Name"].Attributes["onmouseover"] = "showHideSortArrow(this);";
                        headerItem["Name"].Attributes["onmouseout"] = "showHideSortArrow(this);";

                        LinkButton headerStudentIDLink = (LinkButton)headerItem["StudentID"].Controls[0];
                        headerItem["StudentID"].Attributes["style"] = "cursor:pointer;"
                                                                  +
                                                                  (_selectedSortColumn == "StudentID"
                                                                       ? "background: url(../Images/" +
                                                                         (_selectedSortMethod == "DESC"
                                                                              ? "uparrow.gif"
                                                                              : "downarrow.gif") +
                                                                         ") no-repeat right center;"
                                                                       : "");
                        if (_selectedSortColumn == "StudentID") headerItem["StudentID"].Attributes["selectedSortColumn"] = "true";
                        else headerItem["StudentID"].Attributes["selectedSortColumn"] = "false";
                        headerItem["StudentID"].Attributes["onclick"] = "sortRadGridWithCustomHeaderLinks_OnClick(this, event);";
                        headerItem["StudentID"].Attributes["onmouseover"] = "showHideSortArrow(this);";
                        headerItem["StudentID"].Attributes["onmouseout"] = "showHideSortArrow(this);";
                        headerItem["StudentID"].Attributes.Add("studentid", "studentid");

                        LinkButton headerScoreLink = (LinkButton)headerItem["Score"].Controls[0];
                        headerItem["Score"].Attributes["style"] = "cursor:pointer;"
                                                                  +
                                                                  (_selectedSortColumn == "Score"
                                                                       ? "background: url(../Images/" +
                                                                         (_selectedSortMethod == "DESC"
                                                                              ? "uparrow.gif"
                                                                              : "downarrow.gif") +
                                                                         ") no-repeat right center;"
                                                                       : "");
                        if (_selectedSortColumn == "Score") headerItem["Score"].Attributes["selectedSortColumn"] = "true";
                        else headerItem["Score"].Attributes["selectedSortColumn"] = "false";
                        headerItem["Score"].Attributes["onclick"] = "sortRadGridWithCustomHeaderLinks_OnClick(this, event);";
                        headerItem["Score"].Attributes["onmouseover"] = "showHideSortArrow(this);";
                        headerItem["Score"].Attributes["onmouseout"] = "showHideSortArrow(this);";


                        foreach (DataRow row in _columnData.Rows)
                        {
                            var sortColName = row["TR_Sort"].ToString() != "0"
                                                 ? row["Sort"].ToString() + " r(" + row["TR_Sort"].ToString() + ")"
                                                 : row["Sort"].ToString();
                            var bgColor = DataIntegrity.ConvertToBool(row["FieldTest"].ToString()) ? "#FFFF00" : "";
                            LinkButton headerLink = (LinkButton)headerItem[sortColName].Controls[0];

                            // TFS 1123: Disable item preview link for Teacher and School Admin login if assessment content is locked
                            ReportHelper reportHelper = new ReportHelper();
                            reportHelper.UserRoles = SessionObject.LoggedInUser.Roles;
                            if (_isContentLocked && reportHelper.DisableItemLinks())
                            {
                                headerLink.Enabled = false;
                                headerLink.Attributes["style"] = "font-weight: bold; disabled: true;";
                            }
                            else
                            {
                                headerLink.Attributes["style"] = "color:#00F;font-weight:bold;text-decoration:underline;";
                                headerLink.OnClientClick =
                                    "customDialog({ url: '../ControlHost/PreviewTestQuestion.aspx?xID=" +
                                    Encryption.EncryptInt(DataIntegrity.ConvertToInt(row["QuestionID"]))
                                    + "', title: 'Item Preview', maximize: true, maxwidth: 600, maxheight: 450 });return false;";
                                headerItem[sortColName].Attributes["style"] = "cursor:pointer;"
                                                                                         +
                                                                                         (_selectedSortColumn ==
                                                                                          sortColName
                                                                                              ? "background: url(../Images/" +
                                                                                                (_selectedSortMethod == "DESC"
                                                                                                     ? "uparrow.gif"
                                                                                                     : "downarrow.gif") +
                                                                                                ") no-repeat right center;"
                                                                                                + "background-color: " + bgColor
                                                                                              : "background-color:" + bgColor + ";");
                                if (_selectedSortColumn == sortColName)
                                    headerItem[sortColName].Attributes["selectedSortColumn"] = "true";
                                else headerItem[sortColName].Attributes["selectedSortColumn"] = "false";
                                headerItem[sortColName].Attributes["onclick"] =
                                    "sortRadGridWithCustomHeaderLinks_OnClick(this, event);";
                                headerItem[sortColName].Attributes["onmouseover"] = "showHideSortArrow(this, '" + bgColor + "');";
                                headerItem[sortColName].Attributes["onmouseout"] = "showHideSortArrow(this, '" + bgColor + "');";
                            }
                        }
                    }

                    return;
                }

                var cellIndex = e.Item.Cells.Count - _columnData.Rows.Count;
                var counter = 0;
                var dataItem = (DataRowView)(e.Item).DataItem;
                var testResponses = string.Empty;
                var altResponses = string.Empty;
                var answerString = string.Empty;
                var additionalData = string.Empty;

                e.Item.Cells[cellIndex - 3].Wrap = false;

                if (dataItem["Name"].ToString() == "Standards")
                {
                    e.Item.Cells[cellIndex - 3].ID = "standardsRow";
                    e.Item.Cells[cellIndex - 3].ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    e.Item.Cells[3].Attributes.Add("studentid", "studentid");
                }
                if (dataItem["Name"].ToString() == showRigor_checkbox.Value)
                {
                    e.Item.Cells[cellIndex - 3].ID = "rigorRow";
                    e.Item.Cells[cellIndex - 3].ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    e.Item.Cells[3].Attributes.Add("studentid", "studentid");
                }

                foreach (DataRow row in _distractorAnalysisData.Tables[0].Rows)
                {
                    testResponses = row["TestResponses"].ToString();
                    altResponses = row["AltResponses"].ToString();
                    answerString = row["AnswerString"].ToString();
                    additionalData = row["AdditionalData"].ToString();
                    e.Item.Cells[cellIndex - 1].Text = row["PctCorrectDisp"].ToString();

                    if (dataItem["Name"].ToString() == row["Student_Name"].ToString())
                    {
                        //Make student name a link            
                        if (!String.IsNullOrEmpty(row["StudentRecID"].ToString()) && DataIntegrity.ConvertToInt(row["StudentRecID"]) > 0)
                        {
                            e.Item.Cells[2].Attributes.Add("onclick", "window.open('Student.aspx?childPage=yes&xID=" + Standpoint.Core.Classes.Encryption.EncryptString(row["StudentRecID"].ToString()) + "');");
                            e.Item.Cells[2].Attributes.Add("style", "cursor:pointer; text-decoration: underline; color: #034AF3; white-space: nowrap;");
                            e.Item.Cells[2].Attributes.Add("onclickHide", "window.open('Student.aspx?childPage=yes&xID=" + Standpoint.Core.Classes.Encryption.EncryptString(row["StudentRecID"].ToString()) + "');");
                            e.Item.Cells[2].Attributes.Add("styleHide", "cursor:pointer; text-decoration: underline; color: #034AF3; white-space: nowrap;");
                            e.Item.Cells[2].Attributes.Add("studentname", "studentname");
                            e.Item.Cells[2].Attributes.Add("sname", row["Student_Name"].ToString());
                            e.Item.Cells[3].Attributes.Add("studentid", "studentid");
                        }
                        break;
                    }

                    else if (dataItem["Name"].ToString() == row["Demo_Name"].ToString())
                    {
                        LinkButton newLink = new LinkButton();
                        newLink.Click += new EventHandler(newLink_Click);
                        newLink.Attributes["demoLabel"] = row["DemoLabel"].ToString();
                        newLink.Attributes["demoVal"] = row["DemoVal"].ToString();
                        newLink.Text = row["Demo_Name"].ToString();
                        e.Item.Cells[cellIndex - 3].Controls.Add(newLink);
                        e.Item.Cells[3].Attributes.Add("studentid", "studentid");
                        break;
                    }
                }

                if (answerString.Length > 0) //For overall average and demographic cell background colors
                {
                    var answers = answerString.Split((";").ToCharArray());
                    //if (answers.GetUpperBound(0) < _columnData.Rows.Count) return;

                    foreach (var answer in answers)
                    {
                        if (cellIndex >= e.Item.Cells.Count) return;

                        e.Item.Cells[cellIndex].Font.Size = FontUnit.XXSmall;
                        e.Item.Cells[cellIndex].Wrap = false;
                        e.Item.Cells[3].Attributes.Add("studentid", "studentid");

                        cellIndex++;
                        counter++;
                    }
                }
                else
                {
                    if (testResponses.Length == 0) return;
                    if (altResponses.Length == 0) return;

                    foreach (DataRow row in _columnData.Rows)
                    {
                        var fieldTest = row["FieldTest"].ToString() == "1";
                        var displayFieldTestItemData = row["DisplayFieldTestItemData"].ToString() == "yes";
                        var scoreOnTest = row["ScoreOnTest"].ToString();
                        var cellBGColor = System.Drawing.Color.FromName("Green");
                        var trSort = DataIntegrity.ConvertToInt(row["TR_Sort"]);
                        var maxPoints = DataIntegrity.ConvertToInt(row["MaxPoints"]);
                        var masterSort = DataIntegrity.ConvertToInt(row["MasterSort"]);
                        var answer = string.Empty;
                        //var testResponse = testResponses.Substring(masterSort-1, 1);
                        //var altResponse = altResponses.Substring(masterSort == 1 ? 0 : (masterSort * 3) - 3, 3);

                        var testResponse = testResponses.Length >= masterSort ? testResponses.Substring((masterSort - 1), 1) : testResponses.Substring(0, 1);
                        var altResponse = altResponses.Length > ((masterSort * 3) - 3) ? altResponses.Substring((masterSort * 3) - 3, 3) : altResponses.Substring(0, 3);

                        var questionType = row["QuestionType"].ToString();
                        var questionID = DataIntegrity.ConvertToInt(row["QuestionID"]);
                        var rubricPointListString = string.Empty;
                        var rubricPointList = new string[] { };
                        var rubricPointCount = 0;

                        if (additionalData.Length > 0 && additionalData.IndexOf("score_" + questionID + "=,") > -1)
                        {
                            rubricPointListString = additionalData.Substring(additionalData.IndexOf("score_" + questionID + "=,") + ("score_" + questionID + "=,").Length);
                            rubricPointListString = rubricPointListString.Substring(0, rubricPointListString.IndexOf(",|?|"));
                            rubricPointList = rubricPointListString.Split(',');
                            if (trSort > 0)
                            {
                                rubricPointCount = DataIntegrity.ConvertToInt(rubricPointList[trSort - 1].Substring(rubricPointList[trSort - 1].IndexOf("_") + 1));
                            }
                        }

                        if (altResponse != "***" && testResponse == "*" && (questionType == "MC3" || questionType == "MC4" || questionType == "MC5" || questionType == "T"))
                        {
                            answer = "x";
                        }

                        //Logic from legacy system.
                        if (scoreOnTest == "No" && altResponse == "100")
                        {
                            cellBGColor = System.Drawing.Color.FromName("Green");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "green";
                            e.Item.Cells[cellIndex].Style.Add("opacity", "0.4");
                            e.Item.Cells[cellIndex].Style.Add("filter", "alpha(opacity=50)");
                        }
                        else if (scoreOnTest == "No" && altResponse == "000")
                        {
                            cellBGColor = System.Drawing.Color.FromName("Red");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "red";
                            e.Item.Cells[cellIndex].Style.Add("opacity", "0.4");
                            e.Item.Cells[cellIndex].Style.Add("filter", "alpha(opacity=50)");
                        }
                        else if (!displayFieldTestItemData && fieldTest)
                        {
                            cellBGColor = System.Drawing.Color.FromName("Gray");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "gray";
                        }
                        else if (trSort > 0 && rubricPointCount == maxPoints)
                        {
                            cellBGColor = System.Drawing.Color.FromName("Green");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "green";
                            e.Item.Cells[cellIndex].Style.Add("color", "White");
                        }
                        else if (trSort > 0 && rubricPointCount == 0)
                        {
                            cellBGColor = System.Drawing.Color.FromName("Red");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "red";
                            e.Item.Cells[cellIndex].Style.Add("color", "White");
                        }
                        else if (altResponse == "100")
                        {
                            cellBGColor = System.Drawing.Color.FromName("Green");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "green";
                        }
                        else if (altResponse == "***")
                        {
                            cellBGColor = System.Drawing.Color.FromName("LightGray");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "lightgray";
                        }
                        else if (answer == "x")
                        {
                            cellBGColor = System.Drawing.Color.FromName("Gray");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "gray";
                        }
                        else if (altResponse == "000")
                        {
                            cellBGColor = System.Drawing.Color.FromName("Red");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "red";
                        }
                        else if (string.IsNullOrEmpty(altResponse))
                        {
                            cellBGColor = System.Drawing.Color.FromName("Black");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "";
                        }
                        else
                        {
                            cellBGColor = System.Drawing.Color.FromName("Yellow");
                            e.Item.Cells[cellIndex].Attributes["answerType"] = "yellow";
                        }

                        if (cellBGColor != System.Drawing.Color.FromName("Black"))
                        {
                            e.Item.Cells[cellIndex].BackColor = cellBGColor;
                        }

                        e.Item.Cells[cellIndex].Wrap = false;
                        if ((!row["ScoreType"].Equals("P") && !row["ScoreType"].Equals("R")) || altResponse == "000" || altResponse == "100")
                            e.Item.Cells[cellIndex].Style.Add("color", "White");

                        counter += 3;
                        cellIndex++;
                    }
                }
            }

            catch (Exception exc)
            {
                PreventChangeToReport(exc.Message);

            }
        }
        protected void chartSeriesRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {

                var chartGroup = ((HtmlGenericControl)e.Item.FindControl("chartGroup")).InnerHtml;
                var itemID = ((HtmlGenericControl)e.Item.FindControl("itemIdentifier")).InnerHtml;

                var itemLabel = ((System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("phItemLabel"));
                var itemLabelCell = ((System.Web.UI.HtmlControls.HtmlTableCell)e.Item.FindControl("phItemLabelCell"));

                Type dataObjectType = e.Item.DataItem.GetType();
                PropertyInfo dataObjectProperty = dataObjectType.GetProperty("FieldTest");
                if (dataObjectProperty != null)
                {
                    object dataObjectValue = dataObjectProperty.GetValue(e.Item.DataItem, null);
                    if (dataObjectValue != null && dataObjectValue.ToString() == "1") itemLabelCell.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#FFFF00");
                }

                // TFS 1123: Disable item preview link for Teacher and School Admin login if assessment content is locked
                ReportHelper reportHelper = new ReportHelper();
                reportHelper.UserRoles = SessionObject.LoggedInUser.Roles;
                if (_isContentLocked && reportHelper.DisableItemLinks())
                {
                    //itemLabel.Enabled = false;
                    itemLabel.Attributes["style"] = "font-weight: bold; disabled: true;";
                }
                else
                {
                    itemLabel.Style.Add(HtmlTextWriterStyle.Color, "#034AF3");
                    itemLabel.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
                    itemLabel.Style.Add(HtmlTextWriterStyle.TextDecoration, "underline");

                    if (itemLabel != null)
                    {
                        var controlUrl = AnalysisType == Reports.AnalysisType.ItemAnalysis ? "../ControlHost/PreviewTestQuestion.aspx" : "../ControlHost/PreviewStandard.aspx";
                        itemLabel.Attributes.Add("onclick", "openItemPreview('" + controlUrl + "?xID=" + itemID + "'); return false;");
                    }
                }

                var dt = (DataSet)(Session["ItemAnalysisData_" + AnalysisType + "_" + Guid] ?? GetDataTable());

                var barRows = (from DataRow dRow in dt.Tables[0].Rows
                               select new
                               {
                                   chartAmount = 100 * DataIntegrity.ConvertToDouble(dRow["ChartAmt"]),
                                   formattedChartAmount = String.Format("{0:p}", DataIntegrity.ConvertToDouble(dRow["ChartAmt"])),
                                   color = dRow["ChartColor"].ToString(),
                                   chartGroup = dRow["ChartGroup"].ToString()
                               }).Where(t => t.chartGroup == chartGroup);

                ((Repeater)e.Item.FindControl("barLineRepeater")).DataSource = barRows;
                ((Repeater)e.Item.FindControl("barLineRepeater")).DataBind();
            }
        }
        protected void reportGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (!(e.Item is GridDataItem)) return;

            var dataItem = (DataRowView)(e.Item).DataItem;
            var questionList = dataItem["QuestionList"].ToString().Split(',');
            var itemLinks = (Label)e.Item.FindControl("itemLinks");
            var links = new StringBuilder();

            foreach(var questionIDAndSort in questionList)
            {
                //questionArr[0] = Question ID
                //questionArr[1] = Question Number
                var questionArr = questionIDAndSort.Split('|');
                if (links.Length > 0) links.Append(",");

                // TFS 1123: Disable item preview link for Teacher and School Admin login if assessment content is locked
                ReportHelper reportHelper = new ReportHelper();
                reportHelper.UserRoles = SessionObject.LoggedInUser.Roles;
                if (_isContentLocked && reportHelper.DisableItemLinks())
                    links.Append(questionArr[1]);
                else
                    links.Append("<a href=\"javascript:void(0);\" onclick=\"openItemPreview('../ControlHost/PreviewTestQuestion.aspx?xID=" + 
                    Standpoint.Core.Classes.Encryption.EncryptInt(DataIntegrity.ConvertToInt(questionArr[0])) 
                    + "'); return false;\">" + questionArr[1] + "</a>");
            }

            itemLinks.Text = links.ToString();
        }