This is a migrated thread and some comments may be shown as answers.

ItemHierarchicalIndex error on clicking any controls on a page after Expand/Collapse Click

0 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gopa
Top achievements
Rank 1
Gopa asked on 25 Sep 2011, 03:14 AM

Hi  
 I am using  Telerik Rad Control File Version: 2009.3.1208.20

Issue Details: Issue with Rad Grid Expand/Collapse feature.  Expand/Collapse will work as such; Error is when any other control is clicked,  which creates a postback. Error: "Specified argument was out of the range of valid values.Parameter name: ItemHierarchicalIndex"
HierarchyLoadMode="client".  Tried enableViewState =true and still error is there. As this is a user control and hosted in a page which has many other controls the likelihood of the error is more.  I have used the NestedViewTemplate and no detailsTable as per the requirement. 

<

 

telerik:RadScriptManager ID="RadScriptManager1" runat="server" > is in Page where this user control is hosted.  Also there are other user controls with radgrids in the same page.

 


Removed the save buttons from the markup for clarity.  But code behind has the implementation.
aspx code

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DeficienciesDiscovered.ascx.cs"
Inherits="SURV_WebApp.UserControls.DeficienciesDiscovered" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

 <style type="text/css">

.RadGridView
{
    border: solid 0px #cccccc !important;
}
.GridLines .hasNestedTable .nestedHeaderTable td
{
    border-top: 0;
    border-bottom: 1px solid black;
    padding: 0px;
}
.gridviewAlternate
{
 background-color: #F2F2F2;
 color: #333333;
}

.ChangeWrapColor
{        
    background: #F2F2F2;
    color:#333333;
}
.textarea
{
    resize: none;
    font-size:100%;
}

</style>

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> 
<script  language="javascript" type="text/javascript" >
    var defcnt = [];
    var registeredReviewedComments = [];
    var registeredRevComs = [];
    var registeredFoldLink = [];
    var registeredFoldLnk = [];
    var registeredOrgComments = [];
    var registeredOrgComms = [];
    var registeredDropdown = [];
    var registeredValidList = [];
    var registeredinValidList = [];
    var registeredComments = [];
    var registeredDropdown = [];
    var registeredSATComments = [];
    var registeredNegateList = [];
    var registeredSATCommentsHeader = [];

    function btnUpdateSatReview_Click(event_id, atdef_id, className, headerId, lstId, ddlId) {
        var ddlCMSReview = document.getElementById(ddlId);
        var selected_txt, lstbox, ErrorDDReview;
        if (null != ddlCMSReview) {
            selected_txt = ddlCMSReview.options[ddlCMSReview.selectedIndex].text;
        }
        lstbox = document.getElementById(lstId);

        // //count number of def.
        var count = 0;
        // //clear errors
        ErrorDDReview = document.getElementById("error_" + atdef_id);
        //NS - 08052011 - Added ErrorLst and ErrorComment so it can be cleared.
        ErrorLst = document.getElementById("errorlst_" + atdef_id);
        ErrorComment = document.getElementById("errorComment_" + atdef_id);
        if (null != ErrorDDReview) {
            ErrorDDReview.innerHTML = "";
        }
        if (null != ErrorLst) {
            ErrorLst.innerHTML = "";
        }
        if (null != ErrorComment) {
            ErrorComment.innerHTML = "";
        }

        var n = 0;
        var grid = $find("<%=RadGrdDef.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        var rows = MasterTable.get_dataItems();

        for (var i = 0; i < rows.length; i++) {
            if (defcnt[i][1] == atdef_id) {
                //   // update the select value   
                defcnt[i][2] = selected_txt;
            }
            if ((defcnt[i][0] == event_id) && (defcnt[i][2] != "negate")) {
                //   //increment counter
                n++;
            }
        }
        // // If n >0, hide the 'void link.  Otherwise, show it.
        isVoided(event_id, n, className);

        if (selected_txt == "negate") {
            if (lstbox.type == "select-multiple") {
                for (var i = 0; i < lstbox.options.length; i++) {
                    lstbox.options[i].selected = false;
                }
            }
            lstbox.style.display = 'block';
            lstbox.disabled = false;
        }
        else {
            lstbox.style.display = 'none';
            lstbox.disabled = true;
        }
        ShowRequiredStar(headerId);
    }

    function ShowRequiredStar(headerReq) {

        var bNegated = false;
        var ddl, dropdown, GetReqComm, commentsReq, ChangeHeader;

        var grid = $find("<%=RadGrdDef.ClientID %>");
        var MasterTable = grid.get_masterTableView();

        var rows = MasterTable.get_dataItems();
        var ChangeHeader = document.getElementById(headerReq);

        for (var i = 0; i < rows.length; i++) {
            ddl = rows[i].findElement('ddlCMSReview');
            if (null != ddl) {
                dropdown = document.getElementById(ddl);
            }
            GetReqComm = registeredSATCommentsHeader[i];
            if (null != GetReqComm) {
                commentsReq = document.getElementById(GetReqComm);
            }
            //  //negated option is selected
            if (ddl[2].selected) {
                if (null != commentsReq) {
                    commentsReq.innerHTML = "<span style=color:Red;>*</span>Comments 1000 Character limit";
                    bNegated = true;
                }
            }
            else {
                if (null != commentsReq) {
                    commentsReq.innerHTML = "Comments 1000 Character limit";
                }
            }
        }

        if (bNegated) {
            if (null != ChangeHeader) {
                ChangeHeader.innerHTML = "<span style=color:Red;>*</span>CMS Review Categories. <br />Hold the (CTRL) key and left click to select more than one action";
            }
        }
        else {
            if (null != ChangeHeader) {
                ChangeHeader.innerHTML = "CMS Review Categories. <br />Hold the (CTRL) key and left click to select more than one action";
            }
        }
    }

    function Valid_inValid_Options(atdef_id) {

        var grid = $find("<%=RadGrdDef.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        var rows = MasterTable.get_dataItems();

        // //clear errors
        var ErrorDDReview = document.getElementById("error_" + atdef_id);
        if (null != ErrorDDReview) {
            ErrorDDReview.innerHTML = "";
        }

        for (var i = 0; i < rows.length; i++) {
            var ddCMS = rows[i].findElement('ddlCMSReview');
            var ddValid = rows[i].findElement('ddlValidCat');
            var ddInValid = rows[i].findElement('ddlinValid');

            if (ddCMS[1].selected) {
                ddValid.style.display = 'block';
                ddInValid.style.display = 'none';
                ddValid.disabled = false;
                ddInValid.disabled = true;
            }
            else if (ddCMS[2].selected) {
                ddValid.style.display = 'none';
                ddInValid.style.display = 'block';
                ddValid.disabled = true;
                ddInValid.disabled = false;
            }
            else {
                ddValid.style.display = 'none';
                ddInValid.style.display = 'none';
                ddValid.disabled = true;
                ddInValid.disabled = true;
            }
        }
    }

    function InValidChars(obj) {
        if (IsUserInputValid(obj) == false) {
            return true;
        }
        else {
            return false;
        }
        return InValidChars;
    }

    function Validate(isSubmit) {
        // debugger;
        var blnRtrn = true;
        var isinValidChars = false;
        var count = 0;
        var isTrue = true;
        var isNegated = false;
        var Arr_errors = new Array();
        var x = 0;
        var rowCnt = 1;
        var problemlist = document.getElementById('<%=lblscripts.ClientID%>');
        // //check if JS is on
        var h_JSon = document.getElementById('<%=isJSon.ClientID%>');
        h_JSon.value = "1";
        errorList = "";

     //   clearErrors();

        for (var i = 0; i < atdef_ids.length; i++) {
            var ddl, dropdown, selected_txt, ErrorDDReview, ErrorLst, ErrorComment, lstinValid, lstboxinValid, lstValid, lstbox, lstNegate;
            var txtComment, comment;
            var atdef_id = atdef_ids[i];
            var statusCode = status_ids[i];
            ddl = registeredDropdown[i];
            if (null != ddl) {
                dropdown = document.getElementById(ddl);
            }
            if (null != dropdown) {
                selected_txt = dropdown.options[dropdown.selectedIndex].value;
            }
            ErrorDDReview = document.getElementById("error_" + atdef_id);
            ErrorLst = document.getElementById("errorlst_" + atdef_id);
            ErrorComment = document.getElementById("errorComment_" + atdef_id);

            if (statusCode > 21) {
                lstinValid = registeredinValidList[i];
                if (null != lstinValid) {
                    lstboxinValid = document.getElementById(lstinValid);
                }
                var selected_lstboxinValid = lstboxinValid.options[lstboxinValid.selectedIndex].value;
                lstValid = registeredValidList[i];
                if (null != lstValid) {
                    lstbox = document.getElementById(lstValid);
                }
                var selected_lstbox = lstbox.options[lstbox.selectedIndex].value;
            }
            if (statusCode < 21) {
                lstNegate = registeredNegateList[i];
                if (null != lstNegate) {
                    lstbox = document.getElementById(lstNegate);
                }
            }
            txtComment = registeredComments[i];
            if (null != txtComment) {
                comment = document.getElementById(txtComment);
            }
            var ID = defcnt[i][0];

            if (isSubmit == "1") {
                if (null != comment && comment.value != "") {
                    if (comment.value.length > 1000) {
                        addError('row#' + rowCnt + ': Maximum 1000 characters.');
                        errorMessage();
                        ErrorComment.innerHTML = "<br />Error: Maximum 1000 characters.";
                        blnRtrn = false;
                    }

                    var invalidchars = IsUserInputValid(comment.value);
                    if (invalidchars == false) {
                        addError('row#' + rowCnt + ': The Comments field contains one or more of these invalid characters: <,>,;. Please remove any invalid characters.');
                        errorMessage();
                        ErrorComment.innerHTML = "<br />Error: Should not contain characters < > ;";
                        blnRtrn = false;
                    }
                }

                if (selected_txt == 2 || selected_txt == 4 || selected_txt == 5) {
                    if (selected_txt == 2 || selected_txt == 4) {
                        if (lstbox.type == "select-multiple" && (selected_txt == 2)) {
                            for (var j = 0; j < lstbox.options.length; j++) {
                                if (lstbox.options[j].selected == true) {
                                    isTrue = false;
                                    break;
                                }
                            }
                        }
                        if (selected_txt == 4) {
                            if (selected_lstbox != -1) {
                                isTrue = false;
                            }
                        }

                        if (isTrue) {
                            isNegated = true;
                            count++;
                        }
                        else {
                            if (comment.value == "") {
                                isTrue = true;
                                count++;
                            }
                        }

                        if (count > 0 && isTrue == true) {
                            if (isNegated) {
                                if (selected_txt == 2) {
                                    addError('row#' + rowCnt + ': A category is required.');
                                    errorMessage();
                                    ErrorLst.innerHTML = "<br />Error: A category is required";
                                    blnRtrn = false;
                                }
                                else {
                                    //        if(selected_txt == 4)
                                    //        {
                                    //         addError('A category is required if a deficiency is validated(Event Id ' + ID + ' ).' );
                                    //         blnRtrn = false;
                                    //        }
                                }
                            }
                            else {
                                if (selected_txt == 2) {
                                    addError('row#' + rowCnt + ': Comment field is required.');
                                    errorMessage();
                                    ErrorComment.innerHTML = "<br />Error: Comment field is required";
                                    blnRtrn = false;
                                }
                                else {
                                    if (selected_txt == 4) {
                                        addError('row#' + rowCnt + ': Comment field is required.');
                                        errorMessage();
                                        ErrorComment.innerHTML = "<br />Error: Comment field is required";
                                        blnRtrn = false;
                                    }
                                }
                            }
                            x++;
                        }
                        //     //reset variables
                        isTrue = true;
                        isNegated = false;
                    } //end valid lst check
                    if (selected_txt == 5) {
                        if (selected_lstboxinValid != -1) {
                            isTrue = false;
                        }
                        if (isTrue) {
                            isNegated = true;
                            count++;
                        }
                        else {
                            if (null != comment && comment.value == "") {
                                isTrue = true;
                                count++;
                            }
                        }
                        if (count > 0 && isTrue == true) {
                            if (isNegated) {
                                //       addError('A category is required if a deficiency is invalidated(Event Id ' + ID + ' ).' );
                                //       blnRtrn = false;
                            }
                            else {
                                ErrorComment.innerHTML = "<br />Error: Comment field is required";
                                addError('row#' + rowCnt + ': Comment field is required.');
                                errorMessage();
                                blnRtrn = false;
                            }
                            x++;
                        }
                        //     //reset variables
                        isTrue = true;
                        isNegated = false;
                    } //end invalid check
                } //end if
                else {
                    //    //drowdown selected is false
                    if (selected_txt == 0) {
                        ErrorLst.innerHTML = ""; //reset the error
                        ErrorDDReview.innerHTML = "<br />Error: Action is required";
                      addError('row#' + rowCnt + ': Action is required.');
                      errorMessage();
                        x++;
                        isTrue = true;
                        blnRtrn = false;
                    }
                    else if (selected_txt == 1) //reset the errors
                    {
                        ErrorLst.innerHTML = "";
                        ErrorDDReview.innerHTML = "";
                        //NS - 08052011 - Commented the below line as it does not allow to click Review Complete for Pending Status.
                        //blnRtrn = false;
                    }
                }
            }
            else {
                //   //save as draft validation
                if (null != comment && comment.value != "") {
                    if (comment.value.length > 1000) {
                        addError('row#' + rowCnt + ': Maximum 1000 characters.');
                        errorMessage();
                        ErrorComment.innerHTML = "<br />Error: Maximum 1000 characters.";
                       
                        blnRtrn = false;
                    }

                    var invalidchars = IsUserInputValid(comment.value);
                    if (invalidchars == false) {
                        addError('row#' + rowCnt + ': The Comments field contains one or more of these invalid characters: <,>,;. Please remove any invalid characters.');
                        errorMessage();
                        ErrorComment.innerHTML = "<br />Error: Should not contain characters < > ;";
                        blnRtrn = false;
                    }
                }
            }
            rowCnt++;
        }
        return blnRtrn;
       
    }

    function toggleGroup(event) {
        //alert("start of toggleGroup");                
        for (var i = 0; i < atdef_ids.length; i++) {
            //alert("inside forloop");
            var firstMasterTableViewRow = $find("<%= RadGrdDef.MasterTableView.ClientID %>").get_dataItems()[i];
            if (event == 1) {
                //alert("event = 1" + firstMasterTableViewRow.get_expanded());
                if (firstMasterTableViewRow.get_expanded() == false) {
                    firstMasterTableViewRow.set_expanded(true);
                }
                else {
                    firstMasterTableViewRow.set_expanded(false);
                }
            }
            if (event == 0) {
                // alert("event = 0" + firstMasterTableViewRow.get_expanded());
                if (firstMasterTableViewRow.get_expanded()) {
                    firstMasterTableViewRow.set_expanded(true);
                }
                else {
                    firstMasterTableViewRow.set_expanded(false);
                }
            }
        }

        if (event == 1) {
            Collapse();
        }
        if (event == 0) {
            Expand();
        }
    }
    function Collapse() {
        // alert("start of Collapse");
        var rowCollapse = document.getElementById('<%=tdCollapse.ClientID%>');
        var rowExpand = document.getElementById('<%=tdExpand.ClientID%>');
        //alert("what is rowExpand id = " + rowExpand.id); 

        for (var i = 0; i < atdef_ids.length; i++) {
            //alert("inside forloop");
            var firstMasterTableViewRow = $find("<%= RadGrdDef.MasterTableView.ClientID %>").get_dataItems()[i];
            if (firstMasterTableViewRow.get_expanded()) {
                //alert("inside collapse if");
                firstMasterTableViewRow.set_expanded(false);
            }
            else {
                // alert("inside collapse else");
                firstMasterTableViewRow.set_expanded(false);
            }

 

        }

        rowExpand.style.display = "block";
        rowCollapse.style.display = "none";
        document.getElementById('<%=btnExpand.ClientID%>').focus();
    }

    function Expand() {
        //alert("start of Expand");
        var rowCollapse = document.getElementById('<%=tdCollapse.ClientID%>');
        var rowExpand = document.getElementById('<%=tdExpand.ClientID%>');

        for (var i = 0; i < atdef_ids.length; i++) {
            //alert("inside forloop");
            var firstMasterTableViewRow = $find("<%= RadGrdDef.MasterTableView.ClientID %>").get_dataItems()[i];
            if (firstMasterTableViewRow.get_expanded() == false) {
                //alert("inside expand expand if");
                firstMasterTableViewRow.set_expanded(true);
            }
            else {
                //alert("inside expand else");
                firstMasterTableViewRow.set_expanded(true);
            }

        }

        rowExpand.style.display = "none";
        rowCollapse.style.display = "block";
        document.getElementById('<%=btnCollapse.ClientID%>').focus();
    }

    function clear_errors(obj) {
        if (null != obj && obj.innerHTML != "") {
            obj.innerHTML = "";
        }
    }

    var atdef_ids = new Array();
    var status_ids = new Array();

</script>
</telerik:RadCodeBlock>
         
<table id="SATDeficiencies" width="100%" runat="server" style="border: solid 1px black; " >
    <tr style=" padding-bottom:0px; margin:0px">
        <td align="left">
                 <h4><asp:Label ID="LblTitle" runat="server"></asp:Label> </h4> 
                      <asp:Label ID="lblscripts" runat="server"></asp:Label>         
        </td>
    </tr>
    <tr style=" padding-bottom:0px; margin:0px;">
        <td align="left" runat="server" id="tdExpand" style="display:none">
            <asp:Button ID="btnExpand" runat="server" Text="Expand All Comments"  OnClientClick="toggleGroup(0); return false;" ToolTip="Expand All Comments" value="Expand All Comments" />
        <br />
        </td>
        <td align="left" runat="server" id="tdCollapse" style="display:none">
        <asp:Button ID="btnCollapse" Text="Collapse All Comments" OnClientClick="toggleGroup(1); return false;" runat="server" ToolTip="Collapse All Comments" />
        <br />
   </td>      
    </tr>
    <tr>
        <td >
            <div ID="divGV" runat="server" >                          
                <telerik:RadGrid width="99.5%" ID="RadGrdDef" 
                runat="server" onprerender="RadGrdDef_PreRender" OnNeedDataSource="RadGrdDef_NeedDataSource"
                AutoGenerateColumns="False" AllowMultiRowSelection="False" AllowMultiRowEdit ="true"
                AllowSorting="false" AllowPaging="false" BorderColor="White" OnItemCreated="RadGrdDef_ItemCreate"
                CssClass="GridLines"  onitemdatabound="RadGrdDef_ItemDataBound" OnItemCommand="RadGrdDef_ItemCommand"
                >
                      <AlternatingItemStyle BackColor="#F2F2F2"  />
                      <ItemStyle BackColor="White"  />
                      <ClientSettings AllowKeyboardNavigation="true" AllowColumnHide="true" AllowExpandCollapse="true">                              
                        <ClientEvents/>
                      </ClientSettings>
                      <MasterTableView Summary="List of activity deficiencies discovered for a selected Parent Organization"
                            EditMode="InPlace"  AllowNaturalSort="false" DataKeyNames="atdef_id,event_id"
                            CommandItemDisplay="Bottom"   ClientDataKeyNames="atdef_id"
                            ExpandCollapseColumn-Display="true" ExpandCollapseColumn-ButtonType="SpriteButton"
                            ExpandCollapseColumn-HeaderStyle-Width="0%" HierarchyDefaultExpanded="true" HierarchyLoadMode="Client"                            
                            >                          
                            <Columns>  
                            <telerik:GridTemplateColumn UniqueName="TemplateRowNo" HeaderText="Row#"  ShowSortIcon="false" ItemStyle-HorizontalAlign="Center">
                                 <HeaderStyle CssClass="colTitle" Width="1%" />
                                 <ITEMTEMPLATE><asp:Label id="lblRowNum" runat="server"></asp:Label>
                                 </ITEMTEMPLATE>  
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn UniqueName="Identifier" ReadOnly="true" DataField="contractor" HeaderText="Identifier"
                                Display="true" Visible="false" ForceExtractValue="InEditMode" ItemStyle-HorizontalAlign="center" ShowSortIcon="false" >
                                <HeaderStyle CssClass="colTitle" Width="7%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="ATDefId" ReadOnly="true" DataField="atdef_id" HeaderText="ATDEF ID"
                                Display="false" Visible="true" ForceExtractValue="InEditMode"  ShowSortIcon="false" ><HeaderStyle CssClass="colTitle" Width="0%" />
                                <ItemStyle Width="0%" />                  
                            </telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn UniqueName="EventId" DataField="event_id" HeaderText="Event ID"
                                ForceExtractValue="InEditMode" ItemStyle-HorizontalAlign="Right"  ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="5%" />
                                <ItemTemplate>                           
                                    <asp:LinkButton ID="lnkEventIdDisp" runat="server"  CommandName="EventInfo" ForeColor="Blue" >
                                    </asp:LinkButton>
                                </ItemTemplate>                           
                                <EditItemTemplate>
                                    <asp:LinkButton ID="lnkEventId" runat="server"  CommandName="EventInfo"  ForeColor="Blue" >
                                    </asp:LinkButton>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn UniqueName="EventType" ReadOnly="true" DataField="event_type_desc" HeaderText="Event Type"
                                ItemStyle-HorizontalAlign="Center"  Display="true" Visible="false" ForceExtractValue="InEditMode" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="5%"  />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="HPMSEventID" ReadOnly="true" DataField="id" HeaderText="HPMS Event Number"
                                Display="true" Visible="false" ForceExtractValue="InEditMode" ItemStyle-HorizontalAlign="center" ShowSortIcon="false" >
                                <HeaderStyle CssClass="colTitle" Width="10%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="EventDate" ReadOnly="true" DataField="date" HeaderText="Date of Event" ItemStyle-HorizontalAlign="Center"
                                Display="true" Visible="true" ForceExtractValue="InEditMode" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="7%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="EventTime" ReadOnly="true" DataField="time" HeaderText="Time of the unreported marketing event" EmptyDataText="&nbsp;"
                                ItemStyle-HorizontalAlign="Center"  Display="true" Visible="true" ForceExtractValue="InEditMode" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="8%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Location" ReadOnly="true" DataField="CompleteAddr"  HeaderText="Location of Event" EmptyDataText="&nbsp;"
                                ItemStyle-HorizontalAlign="Center"  Display="true" Visible="true" ForceExtractValue="InEditMode" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="9%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="filename" DataField="filename" HeaderText="Ads that reference this unreported marketing event"
                                ForceExtractValue="InEditMode" ItemStyle-HorizontalAlign="Center"  ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="12%" />
                            <ItemTemplate>
                               <asp:Panel ID="hypfilenameDispPan" runat="server" ></asp:Panel>
                            </ItemTemplate>                           
                            <EditItemTemplate>
                               <asp:Panel ID="hypfilenamePan" runat="server" ></asp:Panel>
                            </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="Addate" HeaderText="Date of advertisement"  ShowSortIcon="false" ItemStyle-HorizontalAlign="Center">
                                 <HeaderStyle CssClass="colTitle" Width="5%" />
                                 <ITEMTEMPLATE><asp:Label id="lblAdDate" runat="server"></asp:Label>
                                 </ITEMTEMPLATE>  
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn UniqueName="NamePublication" HeaderText="Name of publication"  ShowSortIcon="false" ItemStyle-HorizontalAlign="Center" >
                                 <HeaderStyle CssClass="colTitle" Width="10%" />
                                 <ITEMTEMPLATE><asp:Label id="lblNamePublication" runat="server"></asp:Label>
                                 </ITEMTEMPLATE>  
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="LocPublication" HeaderText="Location where advertisement was published"  ShowSortIcon="false" ItemStyle-HorizontalAlign="Center">
                                 <HeaderStyle CssClass="colTitle" Width="5%" />
                                 <ITEMTEMPLATE><asp:Label id="lblLocPublication" runat="server"></asp:Label>
                                 </ITEMTEMPLATE>  
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="DefDisc" HeaderText="Deficiencies Discovered" Visible="false" ShowSortIcon="false" ItemStyle-HorizontalAlign="Center">
                                 <HeaderStyle CssClass="colTitle" Width="14%" />
                                 <ITEMTEMPLATE><asp:Label id="lblDefDisc" runat="server"></asp:Label>
                                 </ITEMTEMPLATE>  
                            </telerik:GridTemplateColumn>                            
                            <telerik:GridBoundColumn UniqueName="SummaryRef" ReadOnly="true" DataField="reference" HeaderText="Reference"
                                ItemStyle-HorizontalAlign="Center"  Display="true" Visible="false" ForceExtractValue="InEditMode" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="10%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="OrgConcur" ReadOnly="true" DataField="org_concur" HeaderText="Org. Concurs"
                                ItemStyle-HorizontalAlign="Center" Display="true" Visible="false" ForceExtractValue="InEditMode" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="6%" />                   
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="OrgAction" ReadOnly="true" DataField="org_concur" HeaderText="If yes, identify all actions taken. (see detail below)"
                                ItemStyle-HorizontalAlign="Center"  Display="true" Visible="false" ShowSortIcon="false"><HeaderStyle CssClass="colTitle" Width="10%" /> 
                                <ItemTemplate>
                                  <asp:Label ID="lblActionTaken" runat="server"></asp:Label>
                                </ItemTemplate>                                            
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="sat_valid_text" UniqueName="CMSReviewDisplay" HeaderText="CMS Review"
                                ItemStyle-HorizontalAlign="Center" ForceExtractValue="InEditMode"  HeaderStyle-Wrap="true" AllowFiltering="true" Display="true" Visible="true" ShowSortIcon="false">
                                <HeaderStyle CssClass="colTitle"  Width="9%" />                               
                                <ItemTemplate>
                                   <asp:Label ID="lblReview" runat="server"></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:Label ID="lblCMSReview" runat="server" AssociatedControlID="ddlCMSReview" Style="display:none;">CMS drowdown options</asp:Label>
                                    <asp:DropDownList  runat="server" ID="ddlCMSReview" AppendDataBoundItems="true" style="font-size:100%;"></asp:DropDownList>
                                    <asp:Label ID="lblddlCMS" runat="server" Visible="false"></asp:Label>
                                     <script type="text/javascript">
                                         registeredDropdown.push('<%# Container.FindControl("ddlCMSReview").ClientID %>');                               
                                </script>
                                    <span id="error_<%# DataBinder.Eval(Container.DataItem, "atdef_id")%>" class="error" style="font-size:xx-small"></span>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn  DataField="sat_valid_text" 
                                ItemStyle-HorizontalAlign="Center"  ForceExtractValue="InEditMode"  HeaderStyle-Wrap="true" AllowFiltering="true" Display="true" Visible="true" ShowSortIcon="false">
                                <HeaderStyle CssClass="colTitle" Width="20%" />
                                <HeaderTemplate> 
                                    <asp:Label ID="lblheaderId" runat="server" ></asp:Label> 
                                </HeaderTemplate>                               
                                <ItemTemplate>                                   
                                    <asp:Label ID="lblCMSText" runat="server"></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate><asp:Label ID="Label1" runat="server" AssociatedControlID="lstCMSCat" Style="display:none;">Negate listbox options</asp:Label>
                                    <asp:ListBox runat="server" ID="lstCMSCat" SelectionMode="Multiple"  AppendDataBoundItems="true" Style="display:none;font-size:100%;" >
                                    </asp:ListBox>
                                    <span id="errorlst_<%# DataBinder.Eval(Container.DataItem, "atdef_id")%>" class="error" style="font-size:xx-small"></span>
                                    <script type="text/javascript">
                                        registeredNegateList.push('<%# Container.FindControl("lstCMSCat").ClientID %>');                              
                                    </script>                                                                    
                                    <asp:Label ID="lblValidCat" runat="server" AssociatedControlID="ddlValidCat" Style="display:none; ">Valid dropdown options</asp:Label>
                                    <asp:DropDownList runat="server" ID="ddlValidCat" AppendDataBoundItems="true" style="display:none;font-size:100%"></asp:DropDownList>
                                    <script type="text/javascript">
                                        registeredValidList.push('<%# Container.FindControl("ddlValidCat").ClientID %>');                              
                                    </script>
                                    <asp:Label ID="lblinValid" runat="server" AssociatedControlID="ddlinValid" Style="display:none;">inValid dropdown options</asp:Label>
                                    <asp:DropDownList runat="server" ID="ddlinValid" AppendDataBoundItems="true" style="display:none;font-size:100%;"></asp:DropDownList>
                                    <script type="text/javascript">
                                        registeredinValidList.push('<%# Container.FindControl("ddlinValid").ClientID %>');                              
                                    </script>
                                    <asp:Label ID="lblCMSCatg" runat="server" Visible="false"></asp:Label>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>                               
                            </Columns>                           
                            <NestedViewTemplate>
                                <asp:Panel ID="NestedViewPanel" runat="server"  >
                                    <div>
                                        <fieldset style="padding: 10px;" >                          
                                            <table >
                                                <tbody>
                                                    <tr  id="ReviewedComments" runat="server" visible="false" >                            
                                                        <td align="left"  id="RevComsHeader"  runat="server" style="width:15%; font-size:xx-small; font-weight:bold">CMS SAT Review Comments
                                                        </td>                          
                                                        <td align="left"  id="RevComs"  runat="server" style="width:80%;padding-bottom:10px">
                                                            <asp:Label ID="lblreviewComments" runat="server" ></asp:Label> &nbsp;                           
                                                        </td>
                                                    </tr>
                                                    <tr  id="OrgComments" runat="server" visible="false" >                           
                                                        <td align="left"  id="OrgCommHeader"  runat="server"  style="width:15%;font-size:xx-small; font-weight:bold">&nbsp;Organization Comments
                                                        </td>                          
                                                        <td align="left"  id="OrgComms"  runat="server" style="width:80%;padding-bottom:10px">
                                                           <%# DataBinder.Eval(Container.DataItem, "org_comment")%>  &nbsp;                           
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left"  id="CMSCmms"  runat="server" style="font-size: xx-small;background-color:#CCCCCC;font-weight:bold; width:15%;">
                                                            <asp:Label ID="lblChangeText" runat="server" >Comments 1000 Character limit</asp:Label>
                                                        </td>
                                                        <td align="left"  id="CMSText"  runat="server" >
                                                            <asp:TextBox ID="comments" Columns="50" Rows="4" MaxLength="1000" TextMode="MultiLine" runat="server" CssClass="textarea" ></asp:TextBox>
                                                            <asp:Label ID="Label3" runat="server" AssociatedControlID="comments" Style="display:none;">CMS Compliance Comments 1,000 Characters (CMS only).
                                                            This is a required field ONLY if negate is choosen from dropdown in Pre-Pending or SAT in Review status.
                                                            OR when user selects valid or invalid options from dropdown in PO Completed or SAT in Validation status.
                                                            </asp:Label>
                                                            <script type="text/javascript">
                                                                registeredComments.push('<%# Container.FindControl("comments").ClientID %>');
                                                                registeredSATCommentsHeader.push('<%# Container.FindControl("lblChangeText").ClientID %>');                             
                                                            </script>
                                                            <span id="errorComment_<%# DataBinder.Eval(Container.DataItem, "atdef_id")%>" class="error" style="font-size:xx-small"></span>
                                                        </td>
                                                        <td align="left"  id="CMSComm"  runat="server">
                                                            <asp:Label ID="lblcomments" runat="server">
                                                            </asp:Label>&nbsp;
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </fieldset>
                                    </div>
                                </asp:Panel>                            
                            </NestedViewTemplate>                          
                            <CommandItemTemplate >
                                <table id="tblSatPre" runat="server">
                                    <tr align="left" runat="server" id="trSat">
                                        <td>
                                          <asp:Button ID="btnDraft" runat="server" Text="Save as Draft"  OnClientClick="return Validate(0);" ToolTip="Save as Draft"  Style="font-size: 100%" CommandName="SaveAsDraft" /> &nbsp; &nbsp;
                                          <asp:Button ID="btnSaveData" runat="server" Text="Review Complete"  OnClientClick="return Validate(1);"  ToolTip="Review Complete" Style="font-size: 100%" CommandName="Save" />              
                                       <br />
                                        <asp:Label runat="server" ID="lblPOEnforcementDef" Visible="false" ForeColor="Red">
                                        <strong>Please Note:</strong> The organization is under referral/enforcement action. The information may not continue until the referral/enforcement action is lifted.
                                        </asp:Label>                                  
                                       </td>
                                      
                                    </tr>
                                    <tr style="text-align:left" runat="server" id="trSATinVal">
                                        <td >  
                                         <asp:Button ID="btnCertify" runat="server" Text="Certify Compliance Complete"  ToolTip="Certify Compliance Complete" Style="font-size: 100%"  CommandName="SaveComp" />
                                         </td>
                                    </tr>
                                </table>      
                            </CommandItemTemplate>                      
                      </MasterTableView>
                </telerik:RadGrid>
            </div> 
        </td>
    </tr>
    <tr>
        <td id="Td1"  runat='server'>
          <asp:HiddenField ID="hEventID" runat="Server"/>
          <asp:HiddenField ID="hActivityName" runat="server" />  
          <asp:HiddenField ID="hisSS" runat="Server"/>  
          <asp:HiddenField ID="isJSon" runat="Server"/>
        </td>
    </tr>
</table>
 

code behind:
In PreRender() , rd.MasterTableView.Rebind() is called.

 

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
//using EnterpriseLibrary.Extensions.MetadataContainer.Components;
//using EnterpriseLibrary.BaseObjects.interfaces;
//using EnterpriseLibrary.BaseObjects.Util;
//using CommonUtilities;
using SURV_HttpApplicationDefinition.BaseControl.Surveillance;
using SURV_HttpApplicationDefinition.BasePages.Surveillance;
using SURV_SharedObjects;
using SURV_SharedObjects.SharedObjects.domain.surveillance.transit;
//using EnterpriseLibrary.BaseObjects.impl;
using log4net;
using Telerik.Web.UI;

namespace SURV_WebApp.UserControls
{
    public partial class DeficienciesDiscovered : SurveillanceBaseControl
    {
        IList<SATDeficienciesDiscoveredTO> lstSATDef;
        SATDeficienciesDiscoveredTO cntVoidedTO = new SATDeficienciesDiscoveredTO();
        SATDeficienciesDiscoveredTO _objSATDefDiscTO = new SATDeficienciesDiscoveredTO();
        ActivityStatusTO objActivityStatusTO = new ActivityStatusTO();
        IList<UnreportedDefTO> lstUnreported;
        IList<CodeTO> lstOptions;
        IList<CodeTO> lstNegate;
        IList<CodeTO> lstValid;
        IList<CodeTO> lstInValid;

        IList<OrgActionTO> lstOrgActionTO;
        private Int32 _CodeIdValue;
        string str_title = "";
        string str_error = "";
        private bool _IsDataEntry;
        private bool _isSAT;
        int CountInvalid = 0;
        private string _strActivityClass;
        private Int32 _ActivityId;
        private Int32 _ParentOrgId;
        private string _ParentOrgName;
        private Int32 _AClusId;
        ActivityTypes _uaType;
        int status_code = 0;
        bool isPoEnforcement = false;
        int rowNum = 1;
        string str_style = "";
        ActivityPerformanceResults mypage;
        int IsSave = 0;
        string strCatClientID = "";
        bool even = true;
        string headerId = "";
        int pocode = 0;
        int CommandItem = 0;

        private static readonly ILog log = LogManager.GetLogger(typeof(SATDeficienciesDiscovered));

        public bool IsDataEntry
        {
            get { return _IsDataEntry; }
            set { _IsDataEntry = value; }
        }

        public bool isSAT
        {
            get { return _isSAT; }
            set { _isSAT = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered Page Load method invoked");

            mypage = (ActivityPerformanceResults)this.Page;
            this._AClusId = mypage.AClusId;
            this._ActivityId = mypage.ActivityId;
            this._ParentOrgId = mypage.ParentOrgId;
            this._ParentOrgName = mypage.ParentOrgName;
            this._strActivityClass = mypage.ActivityClass;
            this._isSAT = mypage.isSAT;

            if (this._isSAT)
            {
                //check session for POEnforceFlag              
                if (null == ((SurveillanceModuleBasePage)this.Page).SURVNETSession["POEnforceFlag"])
                {
                    log.Error("SURVNETSession[POEnforceFlag] is null");
                }
                else
                    isPoEnforcement = Convert.ToBoolean(((SurveillanceModuleBasePage)this.Page).SURVNETSession["POEnforceFlag"]);//SURVNETSession["POEnforceFlag"]

            }
            status_code = Convert.ToInt32(((SurveillanceModuleBasePage)this.Page).SURVNETSession["StatusCode"]);

            if (!IsPostBack)
            {
                //hide server side btn
                //btnVeiwEvent_server.Attributes.Add("style", "display:none");
                // btnCertify.Visible = false;
                BtnCertifyComp.Visible = false;
                str_style = "background-color:#F2F2F2;color:#333333;";

                try
                {
                    BindSATDefDisc();
                    IServiceBuffer svcBuff = new ServiceBufferImpl();
                    svcBuff.SetServiceInvocationFocusObject(_objSATDefDiscTO);
                    if (this._isSAT)
                    {
                        log.Debug("SATDeficienciesDiscovered getDeficiencies method invoked");
                        IServiceBuffer serviceBuff = this.SurveillanceSvcFacade.getDeficiencies(svcBuff);
                        log.Debug("SATDeficienciesDiscovered getDeficiencies method ended");

                        lstSATDef = serviceBuff.GetServiceInvocationFocusObject() as IList<SATDeficienciesDiscoveredTO>;
                    }
                    _uaType = (ActivityTypes)Enum.Parse(typeof(ActivityTypes), this._strActivityClass);

                    #region
                    //get all status codes

                    if (null == ((SurveillanceModuleBasePage)this.Page).SURVNETSession["StatusCodes"])
                    {
                        log.Error("SURVNETSession[StatusCodes] is empty");
                    }
                    else
                    {
                        //status codes           
                        log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call start");
                        objActivityStatusTO = (ActivityStatusTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "StatusCodes");
                        log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call ended");
                    }

                    if (null == objActivityStatusTO)
                    {
                        //clear session
                        ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "StatusCodes", null);

                        IServiceBuffer svcBuff_StatusCode = new ServiceBufferImpl();
                        ActivityStatusTO objASTO = new ActivityStatusTO();
                        objASTO.ActivityClass = this._strActivityClass;
                        svcBuff_StatusCode.SetServiceInvocationFocusObject(objASTO);
                        log.Debug("SATDeficienciesDiscovered getAllStatusCodes method invoked");
                        IServiceBuffer serviceBuf_SC = this.SurveillanceSvcFacade.getAllStatusCodes(svcBuff_StatusCode);
                        log.Debug("SATDeficienciesDiscovered getAllStatusCodes method invoked");
                        objActivityStatusTO = serviceBuf_SC.GetServiceInvocationFocusObject() as ActivityStatusTO;
                        ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                                    ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "StatusCodes", objActivityStatusTO);

                    }
                    #endregion

                    if (null != lstSATDef)
                    {
                        if (lstSATDef.Count > 0)
                        {
                            //display title
                            LblTitle.Text = this._ParentOrgName + " Activity Deficiencies Discovered";

                            if ((status_code == objActivityStatusTO.satReviewedCodeId) || (status_code == objActivityStatusTO.satPOPendingCodeId))//status code is less that 20
                            {
                                this._IsDataEntry = false;
                            }
                            //Enable the controls as editable only when the user has data entry access and PO Pending.
                            if (this._IsDataEntry)
                            {
                                for (int i = 0; i <= lstSATDef.Count; i++)
                                {
                                    RadGrdDef.EditIndexes.Add(i);
                                }
                            }

                            tblNoDef.Visible = false;
                            SATDeficiencies.Visible = true;

                            if (_uaType == ActivityTypes.URMEvent)
                            {
                                log.Debug("SATDeficienciesDiscovered getUnreported method invoked");
                                IServiceBuffer servBuff = this.SurveillanceSvcFacade.getUnreported(svcBuff);
                                log.Debug("SATDeficienciesDiscovered getUnreported method invoked");
                                lstUnreported = servBuff.GetServiceInvocationFocusObject() as IList<UnreportedDefTO>;

                                ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                             ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "Unreported", lstUnreported);

                            }

                            #region get ddl options

                            IServiceBuffer svcBuf_options = new ServiceBufferImpl();
                            IMetadataContainer metadataContainer = this.SurveillanceSvcFacade.MetadataContainer;
                            String strCodeName = String.Empty, NegateCodeName = String.Empty, ValidCodeName = String.Empty;
                            String inValidCodeName = String.Empty, satCodeName = String.Empty;

                            if (status_code < objActivityStatusTO.satPOCompletedCodeId)//status code is less that 23
                            {
                                if (null != metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_REVIEW_CODE"])
                                {
                                    strCodeName = metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_REVIEW_CODE"];
                                }
                                if (null != metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_NEGATE_CODE"])
                                {
                                    NegateCodeName = metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_NEGATE_CODE"];
                                }
                            }
                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                if (null != metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_VALID_CODE"])
                                {
                                    satCodeName = metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_VALID_CODE"];
                                }
                                if (null != metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_VALID_CODEID"])
                                {
                                    ValidCodeName = metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_VALID_CODEID"];
                                }
                                if (null != metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_INVALID_CODEID"])
                                {
                                    inValidCodeName = metadataContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_INVALID_CODEID"];
                                }
                            }

                            if (status_code < objActivityStatusTO.satPOCompletedCodeId)//status code is less that 23
                            {
                                //pending or negated options
                                svcBuf_options = this.SurveillanceSvcFacade.GetCodeData(strCodeName, string.Empty);

                                if (null != svcBuf_options)
                                    lstOptions = (List<CodeTO>)svcBuf_options.GetServiceInvocationFocusObject();
                                ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                           ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "PendNeg", lstOptions);
                                svcBuf_options = null;

                                //negate listbox options
                                svcBuf_options = this.SurveillanceSvcFacade.GetCodeData(NegateCodeName, string.Empty);
                                if (null != svcBuf_options)
                                {
                                    lstNegate = (List<CodeTO>)svcBuf_options.GetServiceInvocationFocusObject();
                                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                               ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "LstBoxNegate", lstNegate);

                                }
                            }

                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                svcBuf_options = null;

                                //valid and invalid options for ddl
                                svcBuf_options = this.SurveillanceSvcFacade.GetCodeData(satCodeName, string.Empty);
                                if (null != svcBuf_options)
                                {
                                    lstOptions = (List<CodeTO>)svcBuf_options.GetServiceInvocationFocusObject();
                                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                               ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "PendNeg", lstOptions);
                                }

                                svcBuf_options = null;

                                //valid options for ddl
                                svcBuf_options = this.SurveillanceSvcFacade.GetCodeData(ValidCodeName, string.Empty);
                                if (null != svcBuf_options)
                                {
                                    lstValid = (List<CodeTO>)svcBuf_options.GetServiceInvocationFocusObject();
                                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                          ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "LstBoxValid", lstValid);

                                }

                                svcBuf_options = null;

                                //invalid options for ddl
                                svcBuf_options = this.SurveillanceSvcFacade.GetCodeData(inValidCodeName, string.Empty);
                                if (null != svcBuf_options)
                                {
                                    lstInValid = (List<CodeTO>)svcBuf_options.GetServiceInvocationFocusObject();
                                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                        ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "inValidOpt", lstInValid);
                                }
                            }
                            #endregion

                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                if (status_code == objActivityStatusTO.satValidationCompletedCodeId)//status code is equal to 25
                                {
                                    IMetadataContainer metaContainer = this.SurveillanceSvcFacade.MetadataContainer;

                                    //Get codeId
                                    String strCode_Name = metaContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_VALID_CODE"].ToString();
                                    String strCodeText = metaContainer.ApplicationConfigurationDict["SurveillanceLookup"]["SAT_VALID"].ToString();
                                    IServiceBuffer svcBuf = new ServiceBufferImpl();
                                    svcBuf = this.SurveillanceSvcFacade.GetCodeData(strCode_Name, strCodeText);

                                    if (null != svcBuf)
                                    {
                                        _CodeIdValue = (Int32)((List<CodeTO>)svcBuf.GetServiceInvocationFocusObject())[0].codeId;
                                    }

                                    CountInvalid = this.SurveillanceSvcFacade.getCout_invalidDef(_objSATDefDiscTO.AclusId, _objSATDefDiscTO.ParentOrgId, _CodeIdValue);
                                    Session["CountInvalid"] = CountInvalid.ToString();
                                }

                            }

                            int x = 0;

                            //needed to fold/unfold links in grid
                            foreach (SATDeficienciesDiscoveredTO foldlk in lstSATDef)
                            {
                                lblscripts.Text += "<script  language=\"javascript\" type=\"text/javascript\"> atdef_ids[atdef_ids.length] = '" + foldlk.atdef_id + "'; status_ids[status_ids.length] = '" + status_code + "';  var sat_def= ['" + foldlk.event_id + "','" + foldlk.atdef_id + "','" + foldlk.sat_review_code_id + "']; defcnt[" + x + "]=sat_def;  </script>";
                                x++;
                            }

                        }
                        else
                        {
                            ClearSession();

                            if (status_code < objActivityStatusTO.satPOPendingCodeId)//status code < 22
                            {

                                log.Debug("SATDeficienciesDiscovered getDeficiencies method invoked");
                                IServiceBuffer serviceBuff_isAllVoided = this.SurveillanceSvcFacade.AllEventVoidedCk(svcBuff);
                                log.Debug("SATDeficienciesDiscovered getDeficiencies method ended");

                                cntVoidedTO = serviceBuff_isAllVoided.GetServiceInvocationFocusObject() as SATDeficienciesDiscoveredTO;
                                ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                                         ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "isAllVoided", cntVoidedTO);
                            }

                            lblNoDefTitle.Text = this._ParentOrgName + " Activity Deficiencies Discovered";
                            tblNoDef.Visible = true;
                            SATDeficiencies.Visible = false;

                            //read only
                            if (this._IsDataEntry)
                            {
                                if (isPoEnforcement)
                                {
                                    btnSubmit.Visible = false;
                                    lblPOEnforcement.Visible = true;
                                }
                                else
                                {
                                    showNOBtn.Visible = true;
                                }
                            }
                            else
                            {
                                showNOBtn.Visible = false;
                            }

                            if (status_code >= objActivityStatusTO.satReviewedCodeId)//status code is > 21
                            {
                                showNOBtn.Visible = false;
                                if (this._IsDataEntry)
                                {
                                    if (status_code == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                                    {
                                        BtnCertifyComp.Visible = true;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ClearSession();
                        if (status_code < objActivityStatusTO.satPOPendingCodeId)//status code is < 22
                        {
                            log.Debug("SATDeficienciesDiscovered getDeficiencies method invoked");
                            IServiceBuffer serviceBuff_isAllVoided = this.SurveillanceSvcFacade.AllEventVoidedCk(svcBuff);
                            log.Debug("SATDeficienciesDiscovered getDeficiencies method ended");

                            cntVoidedTO = serviceBuff_isAllVoided.GetServiceInvocationFocusObject() as SATDeficienciesDiscoveredTO;
                            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                                     ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "isAllVoided", cntVoidedTO);
                        }
                        lblNoDefTitle.Text = this._ParentOrgName + " Activity Deficiencies Discovered";
                        tblNoDef.Visible = true;
                        SATDeficiencies.Visible = false;

                        if (this._IsDataEntry)
                        {
                            if (isPoEnforcement)
                            {
                                btnSubmit.Visible = false;
                                lblPOEnforcement.Visible = true;
                            }
                            else
                            {
                                showNOBtn.Visible = true;
                            }
                        }
                        else
                        {
                            showNOBtn.Visible = false;
                        }

                        if (status_code >= objActivityStatusTO.satReviewedCodeId)//status code is > 21
                        {

                            showNOBtn.Visible = false;
                            if (this._IsDataEntry)
                            {
                                if (status_code == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                                {
                                    BtnCertifyComp.Visible = true;
                                    btnDraftSave.Visible = false;
                                    btnSubmit.Visible = false;
                                }
                            }
                        }
                    }

                }
                catch (Exception ex)
                {
                    str_error = "Page: SATDeficienciesDiscovered's Function: Page_Load() got exception:" + ex.Message;
                    log.Error(str_error);
                }
            }
            else
            {
                if (this._ParentOrgId == 0 && this._AClusId == 0)
                {
                    this.mypage.ucProblemList = "Error: Review has already been completed.";
                }
            }
            log.Debug("SATDeficienciesDiscovered Page Load method ended");
        }

        protected void RadGrdDef_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered RadGrdDef_NeedDataSource method invoked");

            try
            {
                if (null != lstSATDef)
                {
                    if (lstSATDef.Count > 0)
                    {
                        // save data table                       
                        ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.AddObject(
                                                                       ((SurveillanceModuleBasePage)this.Page).Session.SessionID, "RadGrdDef", lstSATDef);
                        // display data table
                        RadGrdDef.DataSource = lstSATDef;
                    }
                }
                else
                {
                    //set all lst objects from session
                    lstSATDef = (IList<SATDeficienciesDiscoveredTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "RadGrdDef");

                    //check if lstSATDef is still null if true then browser back button was clicked
                    if (null != lstSATDef)
                    {
                        RadGrdDef.DataSource = lstSATDef;
                        //dropdown
                        lstOptions = (IList<CodeTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "PendNeg");
                        //status codes
                        objActivityStatusTO = (ActivityStatusTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "StatusCodes");
                        if (status_code < objActivityStatusTO.satPOCompletedCodeId)//status code is less that 23
                        {
                            //lstbox
                            lstNegate = (IList<CodeTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "LstBoxNegate");
                        }
                        else
                        {
                            lstValid = (IList<CodeTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "LstBoxValid");

                            //lstbox invalid
                            lstInValid = (IList<CodeTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "inValidOpt");
                        }

                        //unreported
                        lstUnreported = (IList<UnreportedDefTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "Unreported");

                        _uaType = (ActivityTypes)Enum.Parse(typeof(ActivityTypes), this._strActivityClass);

                        cntVoidedTO = (SATDeficienciesDiscoveredTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "isAllVoided");

                        if (Session["CountInvalid"].ToString() != "")
                        {
                            CountInvalid = Convert.ToInt32(Session["CountInvalid"]);
                        }
                    }
                    else
                    {
                        if (this._ParentOrgId == 0 && this._AClusId == 0)
                        {
                            this.mypage.ucProblemList = "Error: The Activity Deficiencies Discovered grid is empty because you have selected the browser back button on the previous page.";
                            this.btnCollapse.Visible = false;
                        }
                    }
                }

                if (null != lstSATDef)
                {
                    if (lstSATDef.Count > 5)
                    {
                        if (Request.Browser.Browser == "Firefox")
                        {
                            divGV.Attributes.Add("style", "overflow:auto;width:100%;height:630px;");
                        }
                        else
                        {
                            divGV.Attributes.Add("style", "overflow:auto;width:100%;height:860px;margin-left:0px");
                        }
                    }
                    else
                    {
                        divGV.Attributes.Add("style", "overflow:auto;width:100%;height:auto;");
                    }
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: RadGrdDef_NeedDataSource() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered RadGrdDef_NeedDataSource method ended");
        }

        protected void RadGrdDef_PreRender(object sender, EventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered RadGrdDef_PreRender method invoked");
            try
            {
                //reset values
                even = true;
                pocode = 0;
                CommandItem = 0;

                if (this._IsDataEntry)
                {
                    if (status_code < objActivityStatusTO.satPOCompletedCodeId)//status code is less that 23
                    {
                        this.RadGrdDef.MasterTableView.GetColumn("CMSReviewDisplay").HeaderText = "<span class='required'>*</span> CMS Review";
                    }
                    if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                    {
                        this.RadGrdDef.MasterTableView.GetColumn("CMSReviewDisplay").HeaderText = "<span class='required'>*</span> CMS Validation Determination";
                    }
                    this.RadGrdDef.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Bottom;

                    btnDraftSave.Visible = true;
                    btnSubmit.Visible = true;

                    if (isPoEnforcement)
                    {
                        btnSubmit.Visible = false;
                    }
                }
                else
                {
                    if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                    {
                        this.RadGrdDef.MasterTableView.GetColumn("CMSReviewDisplay").HeaderText = "CMS Validation Determination";
                    }
                    this.RadGrdDef.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
                }

                switch (_uaType)
                {
                    case ActivityTypes.PublicEvent:
                    case ActivityTypes.TargetedEvent:
                    case ActivityTypes.TargetedPIMA:
                    case ActivityTypes.PIMA:
                        {
                            RadGrdDef.MasterTableView.GetColumn("Identifier").Visible = true;
                            RadGrdDef.MasterTableView.GetColumn("EventType").Visible = true;
                            RadGrdDef.MasterTableView.GetColumn("EventID").Visible = true;
                            RadGrdDef.MasterTableView.GetColumn("EventTime").Visible = false;
                            RadGrdDef.MasterTableView.GetColumn("filename").Visible = false;
                            RadGrdDef.MasterTableView.GetColumn("Addate").Visible = false;
                            RadGrdDef.MasterTableView.GetColumn("NamePublication").Visible = false;
                            RadGrdDef.MasterTableView.GetColumn("LocPublication").Visible = false;
                            RadGrdDef.MasterTableView.GetColumn("DefDisc").Visible = true;

                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                RadGrdDef.MasterTableView.GetColumn("OrgConcur").Visible = true;
                                RadGrdDef.MasterTableView.GetColumn("OrgAction").Visible = true;
                            }
                        }
                        break;
                    case ActivityTypes.AdContentReview:
                        { } break;
                    case ActivityTypes.URMEvent:
                        {
                            RadGrdDef.MasterTableView.GetColumn("EventDate").HeaderText = "Date of Unreported Marketing Event";
                            RadGrdDef.MasterTableView.GetColumn("Location").HeaderText = "Location of unreported marketing event";

                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                RadGrdDef.MasterTableView.GetColumn("OrgConcur").Visible = true;
                                RadGrdDef.MasterTableView.GetColumn("OrgAction").Visible = true;
                            }
                        }
                        break;
                    case ActivityTypes.CCSecretShop:
                        {

                        }
                        break;
                    default: break;
                }
                RadGrdDef.MasterTableView.Rebind();
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: RadGrdDef_PreRender() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered RadGrdDef_PreRender method ended");
        }

        /// <summary>
        ///Binding each row from the TO object that was returned
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        protected void RadGrdDef_ItemDataBound(object sender, GridItemEventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered RadGrdDef_ItemDataBound method invoked");
            StringBuilder orgActions = new StringBuilder();
            StringBuilder satActions = new StringBuilder();
            String brk = "<br />";
            try
            {

                if (e.Item is GridHeaderItem)
                {
                    GridHeaderItem header = (GridHeaderItem)e.Item;//lblheaderId
                    Label lblheaderId = header.FindControl("lblheaderId") as Label;
                    string headertext = lblheaderId.Text;
                    headerId = lblheaderId.ClientID;
                }

                if (e.Item is GridDataItem && !e.Item.Edit)//if (e.Item is GridDataItem)
                {
                    Label lbl = e.Item.FindControl("lblRowNum") as Label;
                    lbl.Text = Convert.ToString((RadGrdDef.MasterTableView.CurrentPageIndex * RadGrdDef.MasterTableView.PageSize) + (e.Item.ItemIndex + 1));

                    if (_uaType == ActivityTypes.PIMA || _uaType == ActivityTypes.PublicEvent || _uaType == ActivityTypes.TargetedEvent || _uaType == ActivityTypes.TargetedPIMA || _uaType == ActivityTypes.CCSecretShop)
                    {
                        Label lblDefDisc = e.Item.FindControl("lblDefDisc") as Label;
                        lblDefDisc.Text = (e.Item.DataItem as SATDeficienciesDiscoveredTO).reference + "  " + (e.Item.DataItem as SATDeficienciesDiscoveredTO).question_description;
                    }

                    Int32 intEventId = ((SATDeficienciesDiscoveredTO)e.Item.DataItem).event_id;
                    LinkButton lnkBtnDisp = (LinkButton)e.Item.FindControl("lnkEventIdDisp");

                    if (null != lnkBtnDisp)
                    {
                        lnkBtnDisp.Text = intEventId.ToString();
                    }

                    #region "SetAdInformation for Display"

                    if (_uaType == ActivityTypes.URMEvent)
                    {
                        if (null != lstUnreported)
                        {
                            Panel hypPan = (Panel)e.Item.FindControl("hypfilenameDispPan");
                            Label lblAdDate = e.Item.FindControl("lblAdDate") as Label;
                            Label lblNamePublication = e.Item.FindControl("lblNamePublication") as Label;
                            Label lblLocPublication = e.Item.FindControl("lblLocPublication") as Label;

                            foreach (UnreportedDefTO objUnreported in lstUnreported)
                            {
                                if (((SATDeficienciesDiscoveredTO)e.Item.DataItem).atdef_id == objUnreported.atdef_id)
                                {
                                    if (null != objUnreported.filename)
                                    {
                                        FileInfo fi = new FileInfo(SurveillanceSvcFacade.GetAdFileLocation(false) + objUnreported.filename);
                                        long lngFileSize = 0;
                                        if (null != fi && fi.Exists)
                                        {
                                            lngFileSize = fi.Length / 1024;
                                        }
                                        HyperLink hypfilenameDisp = new HyperLink();
                                        hypfilenameDisp.ID = "hypFilenameDisp" + e.Item.RowIndex.ToString();
                                        hypfilenameDisp.Text = Path.GetFileNameWithoutExtension(objUnreported.filename) + " (" + Path.GetExtension(objUnreported.filename).Substring(1) + " - " + lngFileSize.ToString() + " KB) <br />";
                                        hypfilenameDisp.NavigateUrl = SurveillanceSvcFacade.GetAdFileLocation(true) + objUnreported.filename;
                                        hypfilenameDisp.Target = "_blank";
                                        hypfilenameDisp.ToolTip = "Opens in a new window";
                                        hypPan.Controls.Add(hypfilenameDisp);
                                    }
                                    lblAdDate.Text += objUnreported.date.ToString() + "<br />";
                                    lblNamePublication.Text += objUnreported.publication_source + "<br />";
                                    lblLocPublication.Text += objUnreported.ad_market + "<br />";
                                }
                            }
                        }
                    }

                    #endregion

                    if (!this._IsDataEntry)
                    {
                        SATDeficienciesDiscoveredTO objSATDefDiscTO = (SATDeficienciesDiscoveredTO)e.Item.DataItem;
                        IList<SATActionTO> lstSATAction = objSATDefDiscTO.lstSATActionTO;
                        Label lblCMSText = e.Item.FindControl("lblCMSText") as Label;
                        Label lblReview = e.Item.FindControl("lblReview") as Label;
                        if (status_code < objActivityStatusTO.satPOCompletedCodeId) //status code < 23
                        {
                            if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review))
                            {
                                lblReview.Text = ((SATDeficienciesDiscoveredTO)e.Item.DataItem).sat_review;
                            }

                            if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinReviewedCodeId || (e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satReviewedCodeId)//status code is 20
                            {
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_code_id > 0)
                                {
                                    if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_code_id == 2)
                                    {
                                        if (null != lstSATAction && lstSATAction.Count > 0)
                                        {
                                            foreach (SATActionTO objSATActionTO in lstSATAction)
                                            {
                                                satActions.Append(objSATActionTO.sat_text);
                                                satActions.Append("<br />");
                                                satActions.Append(brk);
                                            }
                                            if (satActions.Length > brk.Length)
                                            {
                                                lblCMSText.Text = satActions.ToString().Substring(0, satActions.Length - brk.Length);
                                            }
                                            else
                                            {
                                                lblCMSText.Text = null;
                                            }
                                        }
                                    }
                                }
                            }
                        }//end poat code < 23

                        if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                        {
                            //get org selected values
                            IList<OrgActionTO> lstOrgActionTO = objSATDefDiscTO.lstOrgActionTO;
                            Label lblActionTaken = e.Item.FindControl("lblActionTaken") as Label;
                            if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid))
                            {
                                lblReview.Text = ((SATDeficienciesDiscoveredTO)e.Item.DataItem).sat_valid;
                            }

                            if (null != lstOrgActionTO)
                            {
                                if (lstOrgActionTO.Count > 0)
                                {
                                    foreach (OrgActionTO orgAction in lstOrgActionTO)
                                    {
                                        if (orgAction.org_text != null)
                                        {
                                            orgActions.Append(orgAction.org_text);
                                            orgActions.Append(brk);
                                        }
                                    }
                                    if (orgActions.Length > brk.Length)
                                    {
                                        lblActionTaken.Text = orgActions.ToString().Substring(0, orgActions.Length - brk.Length);
                                    }
                                    else
                                    {
                                        lblActionTaken.Text = null;
                                    }
                                }
                                else
                                {
                                    lblActionTaken.Text = " ";
                                }
                            }
                            else
                            {
                                lblActionTaken.Text = " ";
                            }

                            if (null != lstSATAction && lstSATAction.Count > 0)
                            {
                                //valid options
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id == 4)
                                {
                                    foreach (SATActionTO objSATActionTO in lstSATAction)
                                    {
                                        lblCMSText.Text = objSATActionTO.sat_text;
                                    }
                                }

                                //invalid options
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id == 5)
                                {
                                    foreach (SATActionTO objSATActionTO in lstSATAction)
                                    {
                                        lblCMSText.Text = objSATActionTO.sat_text;
                                    }
                                }
                            }
                        }
                    }
                    GridDataItem gdi = e.Item as GridDataItem;
                    TableCell cell = gdi["TemplateRowNo"];
                    cell.Attributes["scope"] = "row";
                }
                if (e.Item is GridEditableItem && e.Item.Edit)
                {
                    Label lblRowNum = e.Item.FindControl("lblRowNum") as Label;
                    lblRowNum.Text = Convert.ToString((RadGrdDef.MasterTableView.CurrentPageIndex * RadGrdDef.MasterTableView.PageSize) + (e.Item.ItemIndex + 1));

                    if (_uaType == ActivityTypes.PIMA || _uaType == ActivityTypes.PublicEvent || _uaType == ActivityTypes.TargetedEvent || _uaType == ActivityTypes.TargetedPIMA || _uaType == ActivityTypes.CCSecretShop)
                    {
                        Label lblDefDisc = e.Item.FindControl("lblDefDisc") as Label;
                        lblDefDisc.Text = (e.Item.DataItem as SATDeficienciesDiscoveredTO).reference + "  " + (e.Item.DataItem as SATDeficienciesDiscoveredTO).question_description;
                    }
                    if (!this._IsDataEntry)
                    {
                        Label lblReview = e.Item.FindControl("lblReview") as Label;
                        lblReview.Text = ((SATDeficienciesDiscoveredTO)e.Item.DataItem).sat_review;
                    }

                    #region "SetAdInformation for Display"
                    if (_uaType == ActivityTypes.URMEvent)
                    {
                        if (null != lstUnreported)
                        {
                            Panel hypPan = (Panel)e.Item.FindControl("hypfilenamePan");
                            Label lblAdDate = e.Item.FindControl("lblAdDate") as Label;
                            Label lblNamePublication = e.Item.FindControl("lblNamePublication") as Label;
                            Label lblLocPublication = e.Item.FindControl("lblLocPublication") as Label;

                            foreach (UnreportedDefTO objUnreported in lstUnreported)
                            {
                                if (((SATDeficienciesDiscoveredTO)e.Item.DataItem).atdef_id == objUnreported.atdef_id)
                                {
                                    if (null != objUnreported.filename)
                                    {
                                        FileInfo fi = new FileInfo(SurveillanceSvcFacade.GetAdFileLocation(false) + objUnreported.filename);
                                        long lngFileSize = 0;
                                        if (null != fi && fi.Exists)
                                        {
                                            lngFileSize = fi.Length / 1024;
                                        }
                                        HyperLink hypfilename = new HyperLink();
                                        hypfilename.ID = "hypFilename" + e.Item.RowIndex.ToString();
                                        hypfilename.Text = Path.GetFileNameWithoutExtension(objUnreported.filename) + " (" + Path.GetExtension(objUnreported.filename).Substring(1) + " - " + lngFileSize.ToString() + " KB) <br />";
                                        hypfilename.NavigateUrl = SurveillanceSvcFacade.GetAdFileLocation(true) + objUnreported.filename;
                                        hypfilename.Target = "_blank";
                                        hypfilename.ToolTip = "Opens in a new window";
                                        hypPan.Controls.Add(hypfilename);
                                    }
                                    lblAdDate.Text += objUnreported.date.ToString() + "<br />";
                                    lblNamePublication.Text += objUnreported.publication_source + "<br />";
                                    lblLocPublication.Text += objUnreported.ad_market + "<br />";
                                }
                            }
                        }
                    }
                    #endregion

                    GridEditableItem gdi = e.Item as GridEditableItem;
                    TableCell cell = gdi["TemplateRowNo"];
                    cell.Attributes["scope"] = "row";

                    Int32 intEventId = ((SATDeficienciesDiscoveredTO)e.Item.DataItem).event_id;

                    LinkButton lnkBtn = (LinkButton)e.Item.FindControl("lnkEventId");
                    if (null != lnkBtn)
                    {
                        lnkBtn.Text = intEventId.ToString();
                    }

                    DropDownList ddlValidCat = (DropDownList)e.Item.FindControl("ddlValidCat");
                    DropDownList ddlinValid = (DropDownList)e.Item.FindControl("ddlinValid");
                    ListBox lstCMSCat = (ListBox)e.Item.FindControl("lstCMSCat");

                    SATDeficienciesDiscoveredTO objSATDefDiscTO = (SATDeficienciesDiscoveredTO)e.Item.DataItem;
                    IList<SATActionTO> lstSATAction = objSATDefDiscTO.lstSATActionTO;

                    if (status_code < objActivityStatusTO.satPOCompletedCodeId) //status code < 23
                    {
                        //508 fix disable controls for when CSS is turned off
                        ddlValidCat.Enabled = false;
                        ddlinValid.Enabled = false;

                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satPrePendingCodeId || (e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinReviewedCodeId)// status code is 19 or 20
                        {
                            //negate options                           
                            lstCMSCat.DataSource = lstNegate;
                            lstCMSCat.DataTextField = "codeText";
                            lstCMSCat.DataValueField = "codeId";
                            lstCMSCat.Attributes.Add("onclick", "javascript:clear_errors(errorlst_" + ((SATDeficienciesDiscoveredTO)e.Item.DataItem).atdef_id + ");return false;");
                            lstCMSCat.DataBind();

                            //Pending or Negate options
                            DropDownList ddlCMSReview = (DropDownList)e.Item.FindControl("ddlCMSReview");
                            ddlCMSReview.DataSource = lstOptions;
                            ddlCMSReview.DataTextField = "codeText";
                            ddlCMSReview.DataValueField = "codeId";
                            ddlCMSReview.Attributes.Add("OnChange", "javascript:btnUpdateSatReview_Click('" + ((SATDeficienciesDiscoveredTO)e.Item.DataItem).event_id + "','" + ((SATDeficienciesDiscoveredTO)e.Item.DataItem).atdef_id + "','" + _uaType + "', '" + headerId + "', '" + lstCMSCat.ClientID + "', '" + ddlCMSReview.ClientID + "');return false;");
                            ddlCMSReview.DataBind();
                            ddlCMSReview.Items.Insert(0, new ListItem(" ", "0"));

                            //get selected item
                            if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinReviewedCodeId)//status code is 20
                            {
                                //lstCMSCat.Enabled = true;
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_code_id > 0)
                                {
                                    ddlCMSReview.SelectedIndex = (e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_code_id;
                                    if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_code_id == 2)
                                    {
                                        lstCMSCat.Attributes.Add("style", "display:block;font-size:100%;");
                                        if (null != lstSATAction && lstSATAction.Count > 0)
                                        {
                                            foreach (SATActionTO objSATActionTO in lstSATAction)
                                            {
                                                for (int i = 0; i < lstCMSCat.Items.Count; i++)
                                                {
                                                    if (lstCMSCat.Items[i].Value == objSATActionTO.Code_Id.ToString())
                                                    {
                                                        lstCMSCat.Items[i].Selected = true;
                                                        lstCMSCat.SelectedValue += objSATActionTO.Code_Id;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }//end poat code id is 19 or 20
                    }//end status code <23

                    if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                    {
                        lstCMSCat.Enabled = false;
                        Label lblActionTaken = e.Item.FindControl("lblActionTaken") as Label;

                        //get org selected values
                        IList<OrgActionTO> lstOrgActionTO = objSATDefDiscTO.lstOrgActionTO;
                        if (null != lstOrgActionTO)
                        {
                            if (lstOrgActionTO.Count > 0)
                            {
                                foreach (OrgActionTO orgAction in lstOrgActionTO)
                                {
                                    if (orgAction.org_text != null)
                                    {
                                        orgActions.Append(orgAction.org_text);
                                        orgActions.Append(brk);
                                    }
                                }
                                if (orgActions.Length > brk.Length)
                                {
                                    lblActionTaken.Text = orgActions.ToString().Substring(0, orgActions.Length - brk.Length);
                                }
                                else
                                {
                                    lblActionTaken.Text = null;
                                }
                            }
                            else
                            {
                                lblActionTaken.Text = " ";
                            }
                        }
                        else
                        {
                            lblActionTaken.Text = " ";
                        }

                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satPOCompletedCodeId || (e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                        {
                            //Valid listbox optons                            
                            ddlValidCat.DataSource = lstValid;
                            ddlValidCat.DataTextField = "codeText";
                            ddlValidCat.DataValueField = "codeId";
                            ddlValidCat.DataBind();

                            //inValid listbox optons                        
                            ddlinValid.DataSource = lstInValid;
                            ddlinValid.DataTextField = "codeText";
                            ddlinValid.DataValueField = "codeId";
                            ddlinValid.DataBind();

                            //Pending or Negate options
                            DropDownList ddlCMSReview = (DropDownList)e.Item.FindControl("ddlCMSReview");
                            ddlCMSReview.DataSource = lstOptions;
                            ddlCMSReview.DataTextField = "codeText";
                            ddlCMSReview.DataValueField = "codeId";
                            ddlCMSReview.Attributes.Add("OnChange", "javascript:Valid_inValid_Options('" + ((SATDeficienciesDiscoveredTO)e.Item.DataItem).atdef_id + "');return false;");
                            ddlCMSReview.DataBind();
                            ddlCMSReview.Items.Insert(0, new ListItem(" ", "0"));

                            if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinValidationCodeId)//status code is 24
                            {
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id > 0)
                                {
                                    ddlCMSReview.SelectedValue = Convert.ToString((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id);
                                }
                                if (null != lstSATAction && lstSATAction.Count > 0)
                                {
                                    //valid options
                                    if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id == 4)
                                    {
                                        //508 fix disable controls for when CSS is turned off
                                        ddlValidCat.Enabled = true;
                                        ddlinValid.Enabled = false;
                                        foreach (SATActionTO objSATActionTO in lstSATAction)
                                        {
                                            ddlValidCat.SelectedValue = Convert.ToString(objSATActionTO.Code_Id);
                                        }
                                    }
                                    //invalid options
                                    if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id == 5)
                                    {
                                        //508 fix disable controls for when CSS is turned off
                                        ddlValidCat.Enabled = false;
                                        ddlinValid.Enabled = true;

                                        foreach (SATActionTO objSATActionTO in lstSATAction)
                                        {
                                            ddlinValid.SelectedValue = Convert.ToString(objSATActionTO.Code_Id);
                                        }
                                    }
                                }
                            }
                        }
                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                        {
                            Label lblddlCMS = e.Item.FindControl("lblddlCMS") as Label;
                            lblddlCMS.Visible = true;
                            lblddlCMS.Text = ((SATDeficienciesDiscoveredTO)e.Item.DataItem).sat_valid;

                            Label lblCMSCatg = e.Item.FindControl("lblCMSCatg") as Label;
                            lblCMSCatg.Visible = true;

                            if (null != lstSATAction && lstSATAction.Count > 0)
                            {
                                lblCMSCatg.Text = lstSATAction[0].sat_text;
                            }
                        }
                    }
                }

                if (e.Item is GridNestedViewItem)
                {
                    SATDeficienciesDiscoveredTO objSATCOMP = (SATDeficienciesDiscoveredTO)e.Item.DataItem;

                    GridNestedViewItem nestedview = (GridNestedViewItem)e.Item;
                    TextBox comments = (TextBox)nestedview.FindControl("comments");
                    HtmlTableCell CMSComm = (HtmlTableCell)nestedview.FindControl("CMSComm");
                    HtmlTableCell CMSText = (HtmlTableCell)nestedview.FindControl("CMSText");
                    HtmlTableCell RevComsHeader = (HtmlTableCell)nestedview.FindControl("RevComsHeader");
                    HtmlTableRow ReviewedComments = (HtmlTableRow)nestedview.FindControl("ReviewedComments");
                    HtmlTableRow OrgComments = (HtmlTableRow)nestedview.FindControl("OrgComments");
                    Label lblChangeText = (Label)nestedview.FindControl("lblChangeText");
                    Label lblreviewComments = (Label)nestedview.FindControl("lblreviewComments");

                    if (this._IsDataEntry)
                    {
                        comments.Attributes.Add("onclick", "javascript:clear_errors(errorComment_" + ((SATDeficienciesDiscoveredTO)e.Item.DataItem).atdef_id + ");return false;");

                        //Label lblChangeText = (Label)nestedview.FindControl("lblChangeText");
                        //lblChangeText.Text = "<span class='required'>*</span>CMS Compliance Comments 1,000 Characters (CMS only)";

                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinReviewedCodeId)//status code is 20
                        {
                            if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text))
                            {
                                comments.Text = Server.HtmlDecode((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text);
                            }
                        }

                        if (status_code >= objActivityStatusTO.satReviewedCodeId)//status code is > 21
                        {
                            if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text))
                            {
                                ReviewedComments.Visible = true;
                                lblreviewComments.Text = Server.HtmlDecode((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text);
                            }
                            if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinValidationCodeId)//status code is 24
                            {
                                if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_text))
                                {
                                    comments.Text = Server.HtmlDecode((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_text);
                                }
                                else
                                {
                                    comments.Text = "";
                                }
                            }

                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).org_comment))
                                {
                                    OrgComments.Visible = true;
                                    String orgCmts = String.Empty;
                                    orgCmts = (e.Item.DataItem as SATDeficienciesDiscoveredTO).org_comment;
                                    orgCmts = Server.HtmlDecode(orgCmts);
                                    (e.Item.DataItem as SATDeficienciesDiscoveredTO).org_comment = orgCmts;
                                }
                                if (status_code >= objActivityStatusTO.satValidationCompletedCodeId)//status code is >= 25
                                {

                                }
                            }
                        }
                    }
                    else
                    {
                        Label lblcomments = (Label)nestedview.FindControl("lblcomments");

                        //Label lblChangeText = (Label)nestedview.FindControl("lblChangeText");
                        lblChangeText.Text = "CMS Compliance Comments 1,000 Characters (CMS only)";

                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satPrePendingCodeId || (e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinReviewedCodeId)// status code is 19 or 20
                        {
                            if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text))
                            {
                                lblcomments.Text = Server.HtmlDecode((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text);
                            }
                        }

                        if (status_code >= objActivityStatusTO.satReviewedCodeId)//status code is > 21
                        {
                            if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text != String.Empty)
                            {
                                ReviewedComments.Visible = true;
                                lblreviewComments.Text = Server.HtmlDecode((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_review_text);
                            }

                            if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinValidationCodeId)//status code is 24
                            {
                                if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_text))
                                {
                                    lblcomments.Text = Server.HtmlDecode((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_text);
                                }
                                else
                                {
                                    lblcomments.Text = "";
                                }
                            }

                            if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                            {
                                if (!String.IsNullOrEmpty((e.Item.DataItem as SATDeficienciesDiscoveredTO).org_comment))
                                {
                                    OrgComments.Visible = true;
                                    String orgCmts = String.Empty;
                                    orgCmts = (e.Item.DataItem as SATDeficienciesDiscoveredTO).org_comment;
                                    orgCmts = Server.HtmlDecode(orgCmts);
                                    (e.Item.DataItem as SATDeficienciesDiscoveredTO).org_comment = orgCmts;
                                }
                                if (status_code >= objActivityStatusTO.satValidationCompletedCodeId)//status code is >= 25
                                {

                                }
                            }
                        }
                    }

                    if (lstSATDef.Count > 1)
                    {
                        Panel panNestedView = (Panel)nestedview.FindControl("NestedViewPanel");
                        if (even)
                        {
                            panNestedView.Attributes.Add("class", "");
                            even = false;
                        }
                        else
                        {
                            panNestedView.Attributes.Add("class", "ChangeWrapColor");
                            even = true;
                        }
                    }

                    RevComsHeader.Attributes.Add("scope", "row");

                    HtmlTableCell OrgCommHeader = (HtmlTableCell)nestedview.FindControl("OrgCommHeader");
                    OrgCommHeader.Attributes.Add("scope", "row");

                    HtmlTableCell CMSCmms = (HtmlTableCell)nestedview.FindControl("CMSCmms");
                    CMSCmms.Attributes.Add("scope", "row");
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: RadGrdDef_ItemDataBound() got exception:" + ex.Message;
                log.Error(str_error);
            }

            log.Debug("SATDeficienciesDiscovered RadGrdDef_ItemDataBound method ended");

        }
        protected void RadGrdDef_ItemCommand(object source, GridCommandEventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered RadGrdDef_ItemCommand method invoked");

            //status codes           
            log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call start");
            objActivityStatusTO = (ActivityStatusTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "StatusCodes");
            log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call ended");

            try
            {
                if (null != lstSATDef)
                {
                    if (e.CommandName == "EventInfo")
                    {
                        NavToEventInfo(((SATDeficienciesDiscoveredTO)e.Item.DataItem).event_id, ((SATDeficienciesDiscoveredTO)e.Item.DataItem).event_type_desc);

                    }
                    else if (e.CommandName == "SaveAsDraft")
                    {
                        //save as draft was clicked
                        IsSave = 0;

                        if (status_code == objActivityStatusTO.satPrePendingCodeId || status_code == objActivityStatusTO.satinReviewedCodeId)//status code is 19 or 20
                        {
                            SaveData(objActivityStatusTO.satinReviewedCodeId); //save status code of 20
                        }
                        if (status_code == objActivityStatusTO.satPOCompletedCodeId || status_code == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                        {
                            SaveData(objActivityStatusTO.satinValidationCodeId);//save status code of 24
                        }
                    }
                    else if (e.CommandName == "Save")
                    {
                        log.Debug("SATDeficienciesDiscovered cntVoidedTO session call start");
                        cntVoidedTO = (SATDeficienciesDiscoveredTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "isAllVoided");
                        log.Debug("SATDeficienciesDiscovered cntVoidedTO session call ended");

                        //save was clicked
                        IsSave = 1;

                        if (null != cntVoidedTO)
                        {
                            //shops were voided
                            if (cntVoidedTO.TotalParendOrg == cntVoidedTO.TotalVoidedShops)
                            {
                                SaveData(objActivityStatusTO.comComplianceCompletedCodeId); //save status code of 27
                            }
                            else
                            {
                                //xml uploaded with NO def.
                                if (status_code == objActivityStatusTO.satPrePendingCodeId || status_code == objActivityStatusTO.satinReviewedCodeId) //status code is 19 or 20
                                {
                                    SaveData(objActivityStatusTO.satReviewedCodeId);//save status code of 21
                                }
                                if (status_code == objActivityStatusTO.satPOCompletedCodeId || status_code == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                                {
                                    SaveData(objActivityStatusTO.satValidationCompletedCodeId);//save status code of 25
                                }
                            }
                        }
                        else
                        {
                            if (status_code == objActivityStatusTO.satPrePendingCodeId || status_code == objActivityStatusTO.satinReviewedCodeId)//status code is 19 or 20
                            {
                                SaveData(objActivityStatusTO.satReviewedCodeId);//save status code of 21
                            }
                            if (status_code == objActivityStatusTO.satPOCompletedCodeId || status_code == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                            {
                                SaveData(objActivityStatusTO.satValidationCompletedCodeId);//save status code of 25
                            }
                        }
                    }
                    else
                    {
                        if (e.CommandName == "SaveComp")
                        {
                            //certify button was clicked
                            IsSave = 3;
                            //there are no def. so save as 27
                            SaveData(objActivityStatusTO.comComplianceCompletedCodeId); //save status code of 27
                        }
                    }
                }
                else
                {
                    if (this._ParentOrgId == 0 && this._AClusId == 0)
                    {
                        this.mypage.ucProblemList = "Error: The Activity Deficiencies Discovered grid is empty because you have selected the browser back button on the previous page.";
                    }
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: RadGrdDef_ItemCommand() got exception:" + ex.Message;
                log.Error(str_error);
            }

            log.Debug("SATDeficienciesDiscovered RadGrdDef_ItemCommand method ended");
        }

        protected void RadGrdDef_ItemCreate(object sender, GridItemEventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered RadGrdDef_ItemCreate method invoked");

            try
            {
                if (e.Item is GridNestedViewItem)
                {
                    GridNestedViewItem nestedview = (GridNestedViewItem)e.Item;

                    HtmlTableCell CMSComm = (HtmlTableCell)nestedview.FindControl("CMSComm");
                    HtmlTableCell CMSText = (HtmlTableCell)nestedview.FindControl("CMSText");
                    Label lblChangeText = (Label)nestedview.FindControl("lblChangeText");

                    if (this._IsDataEntry)
                    {
                        TextBox comments = (TextBox)nestedview.FindControl("comments");
                        //objSATCOMP.poat_code_id;
                        if (lstSATDef[pocode].poat_code_id == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                        {
                            CMSComm.Attributes.Add("style", "display:block");
                            CMSText.Attributes.Add("style", "display:none");
                            Label lblcomments = (Label)nestedview.FindControl("lblcomments");
                            if (!String.IsNullOrEmpty(lstSATDef[pocode].sat_valid_text))
                            {
                                lblcomments.Text = Server.HtmlDecode(lstSATDef[pocode].sat_valid_text);
                            }
                        }
                        else
                        {
                            CMSComm.Attributes.Add("style", "display:none");
                        }

                        if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                        {
                            lblChangeText.Text = "<span class='required'>*</span>Comments 1000 Character limit";
                        }

                        if (Request.Browser.Browser == "Firefox")
                        {
                            comments.Attributes.Add("style", "font-size:medium");
                        }
                        pocode++;
                    }
                    else
                    {
                        CMSText.Attributes.Add("style", "display:none");
                    }
                }
                if (e.Item is GridHeaderItem)
                {
                    GridHeaderItem header = (GridHeaderItem)e.Item;//lblheaderId
                    Label lblheaderId = header.FindControl("lblheaderId") as Label;

                    if (status_code >= objActivityStatusTO.satPOCompletedCodeId)//status code is > 23
                    {
                        lblheaderId.Text = "CMS Validation Categories";
                    }
                    else
                    {
                        lblheaderId.Text = "CMS Review Categories click to select more than one action";
                    }
                }

                if (e.Item is GridEditableItem && e.Item.Edit)
                {
                    if (this._IsDataEntry)
                    {
                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satinValidationCodeId)//status code is 24
                        {
                            SATDeficienciesDiscoveredTO objSATDefDiscTO = (SATDeficienciesDiscoveredTO)e.Item.DataItem;
                            IList<SATActionTO> lstSATAction = objSATDefDiscTO.lstSATActionTO;

                            DropDownList ddlValidCat = (DropDownList)e.Item.FindControl("ddlValidCat");
                            DropDownList ddlinValid = (DropDownList)e.Item.FindControl("ddlinValid");

                            if (null != lstSATAction && lstSATAction.Count > 0)
                            {
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id == 4)
                                {
                                    ddlValidCat.Attributes.Add("style", "display:block;font-size:100%;");
                                }
                                if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).sat_valid_code_id == 5)
                                {
                                    ddlinValid.Attributes.Add("style", "display:block;font-size:100%;");
                                }
                            }
                        }
                        if ((e.Item.DataItem as SATDeficienciesDiscoveredTO).poat_code_id == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                        {
                            DropDownList ddlCMSReview = (DropDownList)e.Item.FindControl("ddlCMSReview");
                            ddlCMSReview.Attributes.Add("style", "display:none");
                        }
                    }
                }
                if (e.Item is GridCommandItem)
                {
                    var item = e.Item as GridCommandItem;
                    if (status_code < objActivityStatusTO.satValidationCompletedCodeId)//status code is less that 25
                    {
                        if (this._IsDataEntry)
                        {
                            item.FindControl("trSATinVal").Visible = false;
                        }
                        if (isPoEnforcement)
                        {
                            item.FindControl("btnSaveData").Visible = false;
                            item.FindControl("lblPOEnforcementDef").Visible = true;
                            btnSubmit.Visible = false;
                        }
                    }
                    else
                    {
                        if (this._IsDataEntry)
                        {
                            if (CountInvalid == 0)
                            {
                                item.FindControl("trSATinVal").Visible = true;
                                item.FindControl("trSat").Visible = false;
                            }
                            else
                            {
                                if (lstSATDef[CommandItem].poat_code_id == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                                {
                                    item.FindControl("trSATinVal").Visible = false;
                                    item.FindControl("trSat").Visible = false;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: RadGrdDef_ItemCreate() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered RadGrdDef_ItemCreate method ended");
        }
        /// <summary>
        /// Gets event_id and activity class name ...pass to event info. page
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        protected void NavToEventInfo(Int32 EventId, string strActivityName) //protected void btnVeiwEvent_Click(object sender, EventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered NavToEventInfo method invoked");

            try
            {
                if (!String.IsNullOrEmpty(strActivityName))
                {
                    Int32 actId = -1;
                    //If activity name is PIMA set the activity Id of Public events
                    if (strActivityName.Equals("PIMA", StringComparison.CurrentCultureIgnoreCase))
                    {
                        String strPEClass = Enum.GetName(typeof(ActivityTypes), ActivityTypes.PublicEvent);
                        IList<SurveillanceActivityTO> lstSurveillanceActivityTO = null;
                        lstSurveillanceActivityTO = Cache["ActivityCacheFile"] as IList<SurveillanceActivityTO>;
                        SurveillanceActivityTO saTo = lstSurveillanceActivityTO.Single(sa => sa.AT_TEXT_CLASS.Equals(strPEClass, StringComparison.CurrentCultureIgnoreCase));
                        if (null != saTo)
                        {
                            actId = Convert.ToInt32(saTo.UniqueId);
                        }
                    }
                    else
                    {
                        String actIdStr = this.SurveillanceSvcFacade.GetActivityIds(strActivityName, null);//3;
                        Int32.TryParse(actIdStr, out actId);
                    }
                    ((SurveillanceModuleBasePage)this.Page).SURVNETSession["Event_ActivityId"] = actId;

                }
                else
                {
                    ((SurveillanceModuleBasePage)this.Page).SURVNETSession["Event_ActivityId"] = this._ActivityId;
                }
                ((SurveillanceModuleBasePage)this.Page).SURVNETSession["EventId"] = EventId;
                ((SurveillanceModuleBasePage)this.Page).SURVNETSession["isVoid"] = 0;
                ((SurveillanceModuleBasePage)this.Page).SURVNETSession["fromComp"] = false;
                ((SurveillanceModuleBasePage)this.Page).SURVNETSession["IsPO"] = "false";
                Response.Redirect("EventsInformation.aspx?PI=052601040002", false);
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: NavToEventInfo() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered NavToEventInfo method ended");
        }

        /// <summary>
        /// based on business logic set status code accordingly
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        protected void btnSaveDraft_Click(object sender, EventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered btnSaveDraft_Click method invoked");

            try
            {
                //status codes           
                log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call start");
                objActivityStatusTO = (ActivityStatusTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "StatusCodes");
                log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call ended");

                //save as draft was clicked
                IsSave = 0;
                if (status_code == objActivityStatusTO.satPrePendingCodeId || status_code == objActivityStatusTO.satinReviewedCodeId)//status code is 19 or 20
                {
                    SaveData(objActivityStatusTO.satinReviewedCodeId); //save status code of 20
                }
                if (status_code == objActivityStatusTO.satPOCompletedCodeId || status_code == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                {
                    SaveData(objActivityStatusTO.satinValidationCodeId);//save status code of 24
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: btnSaveDraft_Click() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered btnSaveDraft_Click method ended");

        }

        /// <summary>
        /// based on business logic set status code accordingly
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered btnSave_Click method invoked");

            try
            {
                log.Debug("SATDeficienciesDiscovered cntVoidedTO session call start");
                cntVoidedTO = (SATDeficienciesDiscoveredTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "isAllVoided");
                log.Debug("SATDeficienciesDiscovered cntVoidedTO session call ended");

                //status codes           
                log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call start");
                objActivityStatusTO = (ActivityStatusTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "StatusCodes");
                log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call ended");

                //save was clicked
                IsSave = 1;

                if (null != cntVoidedTO)
                {
                    //shops were voided
                    if (cntVoidedTO.TotalParendOrg == cntVoidedTO.TotalVoidedShops)
                    {
                        SaveData(objActivityStatusTO.comComplianceCompletedCodeId); //save status code of 27
                    }
                    else
                    {
                        //xml uploaded with NO def.
                        if (status_code == objActivityStatusTO.satPrePendingCodeId || status_code == objActivityStatusTO.satinReviewedCodeId) //status code is 19 or 20
                        {
                            SaveData(objActivityStatusTO.satReviewedCodeId);//save status code of 21
                        }
                        if (status_code == objActivityStatusTO.satPOCompletedCodeId || status_code == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                        {
                            SaveData(objActivityStatusTO.satValidationCompletedCodeId);//save status code of 25
                        }
                    }
                }
                else
                {
                    if (status_code == objActivityStatusTO.satPrePendingCodeId || status_code == objActivityStatusTO.satinReviewedCodeId)//status code is 19 or 20
                    {
                        SaveData(objActivityStatusTO.satReviewedCodeId);//save status code of 21
                    }
                    if (status_code == objActivityStatusTO.satPOCompletedCodeId || status_code == objActivityStatusTO.satinValidationCodeId)//status code is 23 or 24
                    {
                        SaveData(objActivityStatusTO.satValidationCompletedCodeId);//save status code of 25
                    }
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: btnSave_Click() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered btnSave_Click method ended");
        }

        /// <summary>
        /// all deficiencies were invalidated... on button click set
        /// status code 27
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        protected void btnCertify_Click(object sender, EventArgs e)
        {
            log.Debug("SATDeficienciesDiscovered btnCertify_Click method invoked");

            try
            {
                //status codes           
                log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call start");
                objActivityStatusTO = (ActivityStatusTO)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "StatusCodes");
                log.Debug("SATDeficienciesDiscovered objActivityStatusTO session call ended");

                //certify button was clicked
                IsSave = 3;

                //there are no def. so save as 27
                SaveData(objActivityStatusTO.comComplianceCompletedCodeId); //save status code of 27
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: btnCertify_Click() got exception:" + ex.Message;
                log.Error(str_error);
            }
            log.Debug("SATDeficienciesDiscovered btnCertify_Click method ended");
        }

        /// <summary>
        /// Gets selected data from grid, checks for required business logic, saves to IList then pass it to method in odp
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        private void SaveData(int statusCode)
        {
            log.Debug("SATDeficienciesDiscovered SaveData method invoked");

            IServiceBuffer svcBuff = new ServiceBufferImpl();
            IServiceBuffer svcUpdate = new ServiceBufferImpl();
            IList<SATDeficienciesDiscoveredTO> lstSATSave = new List<SATDeficienciesDiscoveredTO>();

            log.Debug("SATDeficienciesDiscovered lstSATDef session call start");
            lstSATDef = (IList<SATDeficienciesDiscoveredTO>)((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.GetObject(this.Session.SessionID, "RadGrdDef");
            log.Debug("SATDeficienciesDiscovered lstSATDef session call ended");

            IList<SATActionTO> lstActionTO = new List<SATActionTO>();
            SATActionTO objActionTO;
            bool isNegated = false;
            string sComments = "";
            int atdef_id = 0;
            int NegatedCnt = 0;
            int lstCnt = 0;
            int rowcnt = 1;
      
            //get hidden value to ck if JS in on
           
            var lstError = new List<string>();
             string isJsOn = Convert.ToString(isJSon.Value);
            //  bool _bisVoided = Convert.ToBoolean(hisVoided.Value);
            string strErrors = string.Empty;
            try
            {
                if (null != lstSATDef)
                {
                    if (lstSATDef.Count > 0 && statusCode != objActivityStatusTO.comComplianceCompletedCodeId)//status code is not 27
                    {
                        int lstSatCnt = lstSATDef.Count;
                        //foreach (GridEditableItem row in RadGrdDef.MasterTableView.Items)
                        //{
                        foreach (GridDataItem item in RadGrdDef.Items)
                        {
                            SATDeficienciesDiscoveredTO objSATDeficienciesDiscoveredTO = new SATDeficienciesDiscoveredTO();

                            if (item.IsInEditMode)
                            {
                                TextBox Comments = (TextBox)item.ChildItem.NestedViewCell.FindControl("Comments");
                                sComments = Comments.Text;

                                //ListBox lst2 = (ListBox)item.FindControl("lstCMSCat");
                            }

                            DropDownList ddlCMSReview = (DropDownList)item.FindControl("ddlCMSReview");
                            int int_selectedIndex = Convert.ToInt32(ddlCMSReview.SelectedValue);

                            //negated
                            if (int_selectedIndex == 2)
                            {
                                ListBox lst = (ListBox)item.FindControl("lstCMSCat");
                                if (lst.SelectedIndex >= 0)
                                {
                                    for (int i = 0; i < lst.Items.Count; i++)
                                    {
                                        objActionTO = new SATActionTO();
                                        if (lst.Items[i].Selected)
                                        {
                                            objActionTO.Code_Id = Convert.ToInt32(lst.Items[i].Value);
                                            objActionTO.Valid_Review_Code_id = int_selectedIndex;
                                            if (null != item.SavedOldValues["atdef_id"])
                                            {
                                                objActionTO.atdef_id = Convert.ToInt32(item.SavedOldValues["atdef_id"]);
                                            }
                                            lstActionTO.Add(objActionTO);
                                        }
                                    }
                                    objSATDeficienciesDiscoveredTO.lstSATActionTO = lstActionTO;
                                }
                                NegatedCnt++;
                            }

                            //valid
                            if (int_selectedIndex == 4)
                            {
                                DropDownList ddlValid = (DropDownList)item.FindControl("ddlValidCat");
                                if (ddlValid.SelectedIndex >= 0)
                                {
                                    objActionTO = new SATActionTO();
                                    objActionTO.Code_Id = Convert.ToInt32(ddlValid.SelectedValue);
                                    objActionTO.Valid_Review_Code_id = int_selectedIndex;
                                    if (null != item.SavedOldValues["atdef_id"])
                                    {
                                        objActionTO.atdef_id = Convert.ToInt32(item.SavedOldValues["atdef_id"]);
                                    }
                                    lstActionTO.Add(objActionTO);
                                    objSATDeficienciesDiscoveredTO.lstSATActionTO = lstActionTO;
                                }
                            }
                            //invalid
                            if (int_selectedIndex == 5)
                            {
                                DropDownList ddinValid = (DropDownList)item.FindControl("ddlinValid");
                                if (ddinValid.SelectedIndex >= 0)
                                {
                                    objActionTO = new SATActionTO();
                                    objActionTO.Code_Id = Convert.ToInt32(ddinValid.SelectedValue);
                                    objActionTO.Valid_Review_Code_id = int_selectedIndex;
                                    if (null != item.SavedOldValues["atdef_id"])
                                    {
                                        objActionTO.atdef_id = Convert.ToInt32(item.SavedOldValues["atdef_id"]);
                                    }
                                    lstActionTO.Add(objActionTO);
                                    objSATDeficienciesDiscoveredTO.lstSATActionTO = lstActionTO;
                                }
                                lstCnt++;
                            }

                            // atdef_id = lstSATDef[x].atdef_id;
                            if (statusCode >= objActivityStatusTO.satinValidationCodeId)//status code is >= 24
                            {
                                objSATDeficienciesDiscoveredTO.sat_valid_code_id = int_selectedIndex;
                                objSATDeficienciesDiscoveredTO.sat_valid_text = Server.HtmlEncode(sComments);
                            }
                            else
                            {
                                objSATDeficienciesDiscoveredTO.sat_review_code_id = int_selectedIndex;
                                objSATDeficienciesDiscoveredTO.sat_review_text = Server.HtmlEncode(sComments);
                            }
                            if (null != item.SavedOldValues["atdef_id"])
                                objSATDeficienciesDiscoveredTO.atdef_id = Convert.ToInt32(item.SavedOldValues["atdef_id"]);

                            //objSATDeficienciesDiscoveredTO.atdef_id = atdef_id;
                            objSATDeficienciesDiscoveredTO.userId = (Session["who"]);
                            objSATDeficienciesDiscoveredTO.isDeficiency = true;
                            if (lstSatCnt == lstCnt)
                            {
                                if (statusCode == objActivityStatusTO.satValidationCompletedCodeId)//status code is 25
                                {
                                    objSATDeficienciesDiscoveredTO.isAllinValid = true;
                                }
                            }
                            // from session
                            objSATDeficienciesDiscoveredTO.ParentOrgId = this._ParentOrgId;
                            objSATDeficienciesDiscoveredTO.AclusId = this._AClusId;
                            objSATDeficienciesDiscoveredTO.poat_code_id = statusCode;
                            objSATDeficienciesDiscoveredTO.satinReviewedCodeId = objActivityStatusTO.satinReviewedCodeId;
                            objSATDeficienciesDiscoveredTO.satReviewedCodeId = objActivityStatusTO.satReviewedCodeId;
                            objSATDeficienciesDiscoveredTO.satinValidationCodeId = objActivityStatusTO.satinValidationCodeId;
                            objSATDeficienciesDiscoveredTO.comComplianceCompletedCodeId = objActivityStatusTO.comComplianceCompletedCodeId;

                            // Gopa: 6/21/11 We need to validate on the server side in any case
                            //if (string.IsNullOrEmpty(isJsOn))
                            //{
                            //JS is OFF
                            objSATDeficienciesDiscoveredTO.isSave = IsSave;
                            objSATDeficienciesDiscoveredTO.int_ddl = int_selectedIndex;
                            if (objSATDeficienciesDiscoveredTO.lstSATActionTO != null)
                            {
                                objSATDeficienciesDiscoveredTO.int_negated = objSATDeficienciesDiscoveredTO.lstSATActionTO.Count;
                            }
                            else
                            {
                                objSATDeficienciesDiscoveredTO.int_negated = 0;
                            }
                            IServiceBuffer svcbufValid = new ServiceBufferImpl();
                            svcbufValid.SetServiceInvocationFocusObject(objSATDeficienciesDiscoveredTO);
                            IServiceBuffer svcbufValidRtrn = new ServiceBufferImpl();

                            svcbufValidRtrn = this.SurveillanceSvcFacade.PerformTOValidation(svcbufValid);
                            if (!svcbufValidRtrn.GetValidationProblemList().IsValidationSuccessful())
                            {
                                foreach (string error in svcbufValidRtrn.GetValidationProblemList().TransformForDisplay())
                                {
                                    log.Error("Error during submitting Compliance summary info.:  " + error);
                                    strErrors += "row# " + (rowcnt) + ":&nbsp;&nbsp;" + error + "<br />";
                                  
                                   lstError.Add("row# " + (rowcnt) + ":&nbsp;&nbsp;" + error + "<br />");
                                 }
                                var LstErrorArray = lstError.ToArray();
                                strErrors = this.SurveillanceSvcFacade.DisplayErrorMessage(LstErrorArray);
                          
                            }

                            else
                            {
                                lstSATSave.Add(objSATDeficienciesDiscoveredTO);
                            }
                          
                            //}
                            //else
                            //{
                            //    lstSATSave.Add(objSATDeficienciesDiscoveredTO); //JS is on
                            //}
                            rowcnt++;

                        }
                    
                     if (statusCode == objActivityStatusTO.satReviewedCodeId)//status code is 21
                        {
                            //deficiencies found in xml upload
                            if (lstSatCnt == NegatedCnt)
                            {
                                isNegated = true;
                                ((SurveillanceModuleBasePage)this.Page).SURVNETSession["isAllNegated"] = isNegated;
                            }
                            else
                            {
                                ((SurveillanceModuleBasePage)this.Page).SURVNETSession["isAllNegated"] = isNegated;
                            }
                        }
                    }
                    else
                    {

                        log.Debug("SATDeficienciesDiscovered  SaveData else statement invoked parentid = " + this._ParentOrgId + " aclusId=" + this._AClusId); //this._ParentOrgId

                        SATDeficienciesDiscoveredTO objSATDefDisTO = new SATDeficienciesDiscoveredTO();
                        objSATDefDisTO.userId = (Session["who"]);
                        objSATDefDisTO.isDeficiency = false;
                        //from session
                        objSATDefDisTO.ParentOrgId = this._ParentOrgId;
                        objSATDefDisTO.AclusId = this._AClusId;
                        objSATDefDisTO.poat_code_id = statusCode;
                        objSATDefDisTO.satinReviewedCodeId = objActivityStatusTO.satinReviewedCodeId;
                        objSATDefDisTO.satReviewedCodeId = objActivityStatusTO.satReviewedCodeId;
                        objSATDefDisTO.satinValidationCodeId = objActivityStatusTO.satinValidationCodeId;
                        objSATDefDisTO.comComplianceCompletedCodeId = objActivityStatusTO.comComplianceCompletedCodeId;
                        lstSATSave.Add(objSATDefDisTO);

                        //zero deficiencies where uploaded
                        if (statusCode == objActivityStatusTO.satReviewedCodeId)//status code is 21
                        {
                            isNegated = true;
                            ((SurveillanceModuleBasePage)this.Page).SURVNETSession["isAllNegated"] = isNegated;

                        }

                        log.Debug("SATDeficienciesDiscovered  SaveData else statement ended parentid = " + this._ParentOrgId + " aclusId=" + this._AClusId); //this._ParentOrgId

                    }
                }
                else
                {
                    log.Debug("SATDeficienciesDiscovered  SaveData else statement invoked parentid = " + this._ParentOrgId + " aclusId=" + this._AClusId); //this._ParentOrgId

                    SATDeficienciesDiscoveredTO objSATDefDisTO = new SATDeficienciesDiscoveredTO();
                    objSATDefDisTO.userId = (Session["who"]);
                    objSATDefDisTO.isDeficiency = false;
                    //from session
                    objSATDefDisTO.ParentOrgId = this._ParentOrgId;
                    objSATDefDisTO.AclusId = this._AClusId;
                    objSATDefDisTO.poat_code_id = statusCode;
                    objSATDefDisTO.satinReviewedCodeId = objActivityStatusTO.satinReviewedCodeId;
                    objSATDefDisTO.satReviewedCodeId = objActivityStatusTO.satReviewedCodeId;
                    objSATDefDisTO.satinValidationCodeId = objActivityStatusTO.satinValidationCodeId;
                    objSATDefDisTO.comComplianceCompletedCodeId = objActivityStatusTO.comComplianceCompletedCodeId;
                    lstSATSave.Add(objSATDefDisTO);

                    //zero deficiencies where uploaded
                    if (statusCode == objActivityStatusTO.satReviewedCodeId)//status code is 21
                    {
                        isNegated = true;
                        ((SurveillanceModuleBasePage)this.Page).SURVNETSession["isAllNegated"] = isNegated;

                    }
                    log.Debug("SATDeficienciesDiscovered  SaveData else statement ended parentid = " + this._ParentOrgId + " aclusId=" + this._AClusId); //this._ParentOrgId
                }

                if (!string.IsNullOrEmpty(strErrors))
                {
                    this.mypage.ucProblemList = strErrors;
                }
                else
                {
                    log.Debug("SATDeficienciesDiscovered UpdateReviewStatus method invoked ");
                    svcBuff.SetServiceInvocationFocusObject(lstSATSave);
                    svcUpdate = this.SurveillanceSvcFacade.UpdateReviewStatus(svcBuff);
                    log.Debug("SATDeficienciesDiscovered UpdateReviewStatus method ended ");

                    #region Clear session varibles
                    ClearSession();

                    //clear these 2 session only after UpdateReviewStatus()
                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "ParentOrgID", null);
                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "AclusId", null);
                    ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "StatusCodes", null);
                    Session["CountInvalid"] = "";
                    #endregion

                    log.Debug("SATDeficienciesDiscovered SaveData method ended ");
                    Response.Redirect("~/SAT/ActivityStatus.aspx?PI=052601040001", false);
                }
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: SaveData() got exception:" + ex.Message;
                log.Error(str_error);
            }
        }

        /// <summary>
        /// Gets session varible and assign to TO
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        private void BindSATDefDisc()
        {
            log.Debug("SATDeficienciesDiscovered BindCountTO method invoked");
            try
            {
                if (this._AClusId > 0)
                    _objSATDefDiscTO.AclusId = this._AClusId;
                else
                    log.Error("SURVNETSession[AClusId] is null");

                if (this._ParentOrgId > 0)
                    _objSATDefDiscTO.ParentOrgId = this._ParentOrgId;
                else
                    log.Error("SURVNETSession[ParentOrgId] is null");

                if (this._ActivityId > 0)
                    _objSATDefDiscTO.activity_id = this._ActivityId;
                else
                    log.Error("SURVNETSession[intActivityID] is empty");

                if (null == this._strActivityClass)
                    log.Error("SURVNETSession[strActivityClass] is empty");
                else
                    _objSATDefDiscTO.ActivityClass = this._strActivityClass;

                _objSATDefDiscTO.statusCode = Convert.ToInt32(((SurveillanceModuleBasePage)this.Page).SURVNETSession["StatusCode"]);
                _objSATDefDiscTO.isCompliance = false;
                log.Debug("SATDeficienciesDiscovered BindCountTO method ended");
            }
            catch (Exception ex)
            {
                str_error = "Page: SATDeficienciesDiscovered's Function: BindCountTO() got exception:" + ex.Message;
                log.Error(str_error);
            }
        }

        private void ClearSession()
        {
            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "RadGrdDef", null);
            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "PendNeg", null);
            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "LstBoxVP", null);
            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "inValidOpt", null);
            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "Unreported", null);
            ((SurveillanceModuleBasePage)this.Page).SurveillanceSvcFacade.SessionContainer.RemoveObject(this.Session.SessionID, "isAllVoided", null);

        }

    }
}

 

Looks like after expand/collapse is performed on the client, when the user clicks any control on the page which performs a postback,  hierarchy index error is thrown. Let me know how to solve this.

thanks
Gopa

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Gopa
Top achievements
Rank 1
Share this question
or