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

2013.2.717 Grid Rows Not Rendering

3 Answers 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 07 Aug 2013, 02:48 PM
So I recently updated to 2013.2.717 from 2013.2.611 in order to fix an issues with the RadMenus opening in the wrong direction when a RadDropDownList was on the page. While this did fix my issue, it created a far worse one! I have a grid that is using the OnNeedDataSource event. I can see that the server side code is being run, and my DataSource is being set appropriately, however the rows are never rendered?!?! This works 100% in 611, but something changed, and using 717 the grid will just not refresh. Can anyone give me some insight as to what changed that might have caused this to happen.

P.S. I tried the latest internal build 2013.2.806, but it did not remedy the problem.

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 12 Aug 2013, 06:53 AM
Hello,

With the provided information it is too hard to find the source of issue.

Could you share your full page source code along with the code-behind file content? Thus all the people who want to help you will have better understanding of your case.

Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Xorcist
Top achievements
Rank 1
answered on 10 Sep 2013, 06:22 PM
There is a lot of code here, and I can't list out the shell or master page code we have. But this page also has designer issues do to some Eval lines added to the ASPX file. Basically the search runs, I see data on the back end, but it never gets populated. I always see the NoRecordsTemplate. This only happens with newer DLLs, the older DLL works fine (but as I stated the menus open in the wrong direction due to this).

PAGE
<%@ Page Language="C#" MasterPageFile="~/TrainingSuite.master" AutoEventWireup="true" Inherits="Personnel" Codebehind="Personnel.aspx.cs" %>
 
<asp:Content ID="Title" ContentPlaceHolderID="contentTitle" runat="server">
  [ Personnel Admin ]
</asp:Content>
 
<asp:Content ID="Head" ContentPlaceHolderID="contentHead" Runat="Server">
</asp:Content>
 
<asp:Content ID="Body" ContentPlaceHolderID="contentBody" Runat="Server">
 
  <telerik:RadAjaxManagerProxy ID="contentAjaxManagerProxy" runat="server">
    <AjaxSettings>
      <telerik:AjaxSetting AjaxControlID="rdlSearch_Site" EventName="SelectedIndexChanged">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="searchPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="rdlSearch_Crew" EventName="SelectedIndexChanged">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="searchPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="btnSearch" EventName="Click">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="userGrid" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="userGrid">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="userGrid" UpdatePanelRenderMode="Inline" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="btnLookup_Search" EventName="Click">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="lookupPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="btnLookup_Insert" EventName="Click">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="lookupPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="btnUser_Load" EventName="Click">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="userPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="rdlUser_Site" EventName="SelectedIndexChanged">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="userPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="rdlUser_Crew" EventName="SelectedIndexChanged">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="userPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
      <telerik:AjaxSetting AjaxControlID="btnUser_Save" EventName="Click">
        <UpdatedControls>
          <telerik:AjaxUpdatedControl ControlID="userPanel" LoadingPanelID="contentAjaxLoadingPanel" UpdatePanelRenderMode="Block" />
        </UpdatedControls>
      </telerik:AjaxSetting>
    </AjaxSettings>
  </telerik:RadAjaxManagerProxy>
 
  <telerik:RadAjaxLoadingPanel BackColor="WhiteSmoke" runat="server" ID="contentAjaxLoadingPanel" EnableEmbeddedSkins="false" InitialDelayTime="500" Transparency="30">
  </telerik:RadAjaxLoadingPanel>
 
  <telerik:RadWindowManager ID="contentWindowManager" runat="server">
    <Windows>
      <telerik:RadWindow ID="winLookup" Behaviors="Close" EnableShadow="true" Height="300" IconUrl="../img/ico/find.png" InitialBehaviors="None" Modal="true" OnClientShow="winLookup_OnClientShow" OnClientClose="winLookup_OnClientClose" runat="server" Title="New User Lookup" RestrictionZoneID="Zone" Width="508">
        <ContentTemplate>
          <asp:Panel DefaultButton="btnLookup_Insert" Height="200" ID="lookupPanel" runat="server" style="padding:4px;" Width="470">
            <div style="float:left; height:95%; width:40%;">
              <fieldset style="padding-left:8px; height:100%">
                <legend>Search Criteria</legend>
                <div style="padding-bottom:4px;" title="Last Name Filter"><telerik:RadTextBox ID="txtLookup_LastName" runat="server" EmptyMessage="Last Name"></telerik:RadTextBox></div>
                <div style="padding-bottom:4px;" title="First Name Filter"><telerik:RadTextBox ID="txtLookup_FirstName" runat="server" EmptyMessage="First Name"></telerik:RadTextBox></div>
                <div style="padding-bottom:4px;" title="User Name Filter"><telerik:RadTextBox ID="txtLookup_UserName" runat="server" EmptyMessage="User Name"></telerik:RadTextBox></div>
                <div style="padding-bottom:8px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkLookup_IncludeDisabled" runat="server" /></span>Include Disabled Accounts</div>
                <div style="padding-bottom:8px;"><telerik:RadButton ButtonType="SkinnedButton" ID="btnLookup_Search" OnClientClicking="btnLookup_Search_ClientClicking" OnClick="btnLookup_Search_Click" runat="server" Text="Perform Lookup" Width="150px"></telerik:RadButton></div>
                <div style="padding-bottom:4px;"><telerik:RadButton ButtonType="SkinnedButton" ID="btnLookup_Insert" OnClientClicking="btnLookup_Insert_ClientClicking" OnClick="btnLookup_Insert_Click" runat="server" Text="Add Selected User" Width="150px"></telerik:RadButton></div>
              </fieldset>
            </div>
            <div style="float:left; height:95%; width:60%;">
              <fieldset style="padding-left:8px; height:100%">
                <legend>Search Results</legend>
                <div style="height:85%;padding-bottom:4px;padding-right:4px;">
                  <telerik:RadListBox ID="rlbLookup" runat="server" Height="100%" style="padding:0px !important;" Width="100%" >
                    <ItemTemplate>
                        <div title=<%# Eval("adUser").ToString().Replace(" ", " ").Split('|')[0] %>, <%# Eval("adUser").ToString().Replace(" ", " ").Split('|')[1] %> (<%# Eval("adUser").ToString().Replace(" ", " ").Split('|')[2] %>)>
                        <div style="display:inline-block; overflow:hidden; width:16px; white-space:nowrap;"><%# AccountStatus(Eval("adUser").ToString().Split('|')[3]) %></div>
                        <div style="display:inline-block; padding-left:4px; overflow:hidden; text-overflow:ellipsis; width:100px; white-space:nowrap;"><%# Eval("adUser").ToString().Split('|')[0] %>, <%# Eval("adUser").ToString().Split('|')[1] %></div>
                            <div style="display:inline-block; padding-left:4px; overflow:hidden; text-overflow:ellipsis; width:90px; white-space:nowrap;"><%# Eval("adUser").ToString().Split('|')[2] %></div>
                        </div>
                    </ItemTemplate>
                  </telerik:RadListBox>
                </div>
              </fieldset>
            </div>
            <asp:HiddenField ID="hdnError" runat="server" value=""/>
            <asp:HiddenField ID="hdnUser" runat="server" value=""/>
          </asp:Panel>
        </ContentTemplate>
      </telerik:RadWindow>
      <telerik:RadWindow ID="winUser" Behaviors="Close" EnableShadow="true" Height="480" IconUrl="../img/ico/profile.png" InitialBehaviors="None" Modal="true" OnClientShow="winUser_OnClientShow" OnClientClose="winUser_OnClientClose" runat="server" Title="User Account Settings" RestrictionZoneID="Zone" Width="799">
        <ContentTemplate>
          <telerik:RadButton ButtonType="SkinnedButton" ID="btnUser_Load" OnClick="btnUser_Load_Click" runat="server" style="display:none;" ></telerik:RadButton>
          <asp:Panel DefaultButton="btnUser_Save" Height="400" ID="userPanel" runat="server" style="padding:4px;" Width="761">
            <telerik:RadTabStrip ID="tabConfig" MultiPageID="rmpConfig" OnClientTabSelected="tabConfig_ClientTabSelected" runat="server" SelectedIndex="0">
              <Tabs>
                <telerik:RadTab Text="Employee Info" Value="1" >
                </telerik:RadTab>
                <telerik:RadTab Text="User Security" Value="2">
                </telerik:RadTab>
                <telerik:RadTab Text="Ops Training Performance" Value="3">
                </telerik:RadTab>
                <telerik:RadTab Text="L . A . S . E . R ." Enabled="false" Value="4">
                </telerik:RadTab>
                <telerik:RadTab Text="Instructor Evals" Enabled="false" Value="5">
                </telerik:RadTab>
                <telerik:RadTab Text="Training Requests" Enabled="false" Value="6">
                </telerik:RadTab>
              </Tabs>
            </telerik:RadTabStrip>
            <telerik:RadMultiPage runat="server" ID="rmpConfig" SelectedIndex="0">
                <telerik:RadPageView runat="server" ID="rpvUserInfo">
                  <div style="border:1px solid gray; border-top:none; padding:4px; height:330px;">
                    <div style="float:left; height:100%; width:250px;">
                      <fieldset style="padding-left:8px; height:95%;">
                        <legend>Profile Info</legend>
                        <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">Last Name:</span></div><telerik:RadTextBox ID="txtUser_LastName" runat="server" Width="150px"></telerik:RadTextBox></div>
                        <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">First Name:</span></div><telerik:RadTextBox ID="txtUser_FirstName" runat="server" Width="150px"></telerik:RadTextBox></div>
                      </fieldset>
                    </div>
                    <div style="float:left; height:100%; width:250px;">
                      <fieldset style="padding-left:8px; height:95%;">
                        <legend>Account Info</legend>
                        <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">User Name:</span></div><telerik:RadTextBox ID="txtUser_UserName" ReadOnly="true" runat="server" Width="150px"></telerik:RadTextBox></div>
                        <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">Employee ID:</span></div><telerik:RadTextBox ID="txtUser_EmployeeID" ReadOnly="true" runat="server" Width="150px"></telerik:RadTextBox></div>
                      </fieldset>
                    </div>                           
                    <div style="float:left; height:100%; width:250px;">
                      <fieldset style="padding-left:8px; height:95%;">
                        <legend>Status Info</legend>
                        <div><div style="display:inline-block; padding-right:4px; text-align:right; width:40px;">Active:</div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_Active" runat="server" /></span></div>
                        <div><div style="display:inline-block; padding-right:4px; text-align:right; width:40px;"><span style="position:relative; top:2px;">Site:</span></div><telerik:RadDropDownList AutoPostBack="true" ID="rdlUser_Site" OnSelectedIndexChanged="rdlUser_Site_SelectedIndexChanged" runat="server" Width="180px"></telerik:RadDropDownList></div>
                      </fieldset>
                    </div>
                  </div>
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="rpvUserSecurity">
                  <div style="border:1px solid gray; border-top:none; padding:4px; height:330px;">
                    <div style="float:left; height:100%; width:250px;">
                      <fieldset style="padding-left:8px; height:95%;">
                        <legend>Administration</legend>
                        <div style="padding-left:12px; padding-top:4px;">
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_SiteAdmin" runat="server" /></span>Site Admin</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_CorporateAdmin" runat="server" /></span>Corporate Admin</div>
                        </div>
                      </fieldset>
                    </div>
                    <div style="float:left; height:100%; width:250px;">
                      <fieldset style="padding-left:8px; height:95%;">
                        <legend>Ops Training Performance</legend>
                        <div style="padding-left:12px; padding-top:4px;">
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_OPSTrainingInstructor" runat="server" /></span>Ops Training Instructor</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_ShiftManager" runat="server" /></span>Shift Manager</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_Evaluator" runat="server" /></span>Evaluator</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_SiteOPSManagement" runat="server" /></span>Site Ops Management</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_SiteOTM" runat="server" /></span>Site Ops Training Manager</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_OPSPeers" runat="server" /></span>Ops Peers</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_CorporateOTM" runat="server" /></span>Corporate Ops Training Manager</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_Clerical" runat="server" /></span>Clerical</div>
                        </div>
                      </fieldset>
                    </div>                           
                    <div style="float:left; height:100%; width:250px;">
                      <fieldset style="padding-left:8px; height:95%;">
                        <legend>L . A . S . E . R .  &  Instructor Evals</legend>
                          <div style="padding-left:12px; padding-top:4px;">
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_InstructorEvaluator" runat="server" /></span>Instructor Evaluator</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_TrainingInstructorSME" runat="server" /></span>Training Instructor / SME</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_SiteTrainingManager" runat="server" /></span>Site Training Manager</div>
                          <div style="padding-bottom:4px;"><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_CorporateTrainingManager" runat="server" /></span>Corporate Training Manager</div>
                        </div>
                      </fieldset>
                    </div>
                  </div>
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="rpvModOpsTrainingPerformance">
                  <div style="border:1px solid gray; border-top:none; padding:4px; height:330px;">
                    <div style="float:left; height:100%; width:250px;">
                      <div style="height:40%;">
                        <fieldset style="padding-left:8px; height:95%;">
                          <legend>Credentials</legend>
                          <div style="padding-left:12px; padding-top:4px;">
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_Licensed" runat="server" /></span>Licensed Operator</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_AccessILT" runat="server" /></span>ILT Access</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_AccessLORT" runat="server" /></span>LORT Access</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_AccessNLORT" runat="server" /></span>NLORT Access</div>
                          </div>
                        </fieldset>
                      </div>
                      <div style="height:25%;">
                        <fieldset style="padding-left:8px; height:95%;">
                          <legend>Qualifications</legend>
                          <div style="padding-left:12px; padding-top:4px;">
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_QALShiftTechnicalAdvisor" runat="server" /></span>Shift Technical Advisor (STA)</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_QALShiftManager" runat="server" /></span>Shift Manager (SM)</div>
                          </div>
                        </fieldset>
                      </div>
                      <div style="height:32%;">
                        <fieldset style="padding-left:8px; height:95%;">
                          <legend>Assignments</legend>
                          <div style="padding-left:12px;">
                            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:45px;"><span style="position:relative; top:2px;">Crew:</span></div><telerik:RadDropDownList AutoPostBack="true" ID="rdlUser_Crew" OnSelectedIndexChanged="rdlUser_Crew_SelectedIndexChanged" runat="server" Width="160px"></telerik:RadDropDownList></div>
                            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:45px;"><span style="position:relative; top:2px;">Group:</span></div><telerik:RadDropDownList ID="rdlUser_CrewGroup" runat="server" Width="160px"></telerik:RadDropDownList></div>
                            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:45px;"><span style="position:relative; top:2px;">Position:</span></div><telerik:RadDropDownList ID="rdlUser_Position" runat="server" Width="160px"></telerik:RadDropDownList></div>
                          </div>
                        </fieldset>
                      </div>
                    </div>
                    <div style="float:left; height:100%; width:250px;">
                      <div style="height:32%;">
                        <fieldset style="padding-left:8px; height:95%;">
                          <legend>ILT</legend>
                          <div style="padding-left:12px; padding-top:4px;">
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_ILTOperator" runat="server" /></span>Operator</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_ILTInstructor" runat="server" /></span>Instructor</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_ILTEvaluator" runat="server" /></span>Evaluator</div>
                          </div>
                        </fieldset>
                      </div>
                      <div style="height:32%;">
                        <fieldset style="padding-left:8px; height:95%;">
                          <legend>LORT</legend>
                          <div style="padding-left:12px; padding-top:4px;">
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_LORTOperator" runat="server" /></span>Operator</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_LORTInstructor" runat="server" /></span>Instructor</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_LORTEvaluator" runat="server" /></span>Evaluator</div>
                          </div>
                        </fieldset>
                      </div>
                      <div style="height:33%;">
                        <fieldset style="padding-left:8px; height:95%;">
                          <legend>NLORT</legend>
                          <div style="padding-left:12px; padding-top:4px;">
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_NLORTOperator" runat="server" /></span>Operator</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_NLORTInstructor" runat="server" /></span>Instructor</div>
                            <div><span style="position:relative; left:-2px; top:2px"><asp:CheckBox ID="chkUser_NLORTEvaluator" runat="server" /></span>Evaluator</div>
                          </div>
                        </fieldset>
                      </div>
                    </div>                      
                  </div>
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="rvpModLASER">
                  <div style="border:1px solid gray; border-top:none; padding:4px; height:330px;">
                    Four
                  </div>
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="rvpModInstructorEvals">
                  <div style="border:1px solid gray; border-top:none; padding:4px; height:330px;">
                    Five
                  </div>
                </telerik:RadPageView>
                <telerik:RadPageView runat="server" ID="rvpModTrainingRequests">
                  <div style="border:1px solid gray; border-top:none; padding:4px; height:330px;">
                    Six
                  </div>
                </telerik:RadPageView>
            </telerik:RadMultiPage>
            <div style="float:left; padding:8px 0px 0px 8px;">
              <asp:Label ID="lblUser_Notice" ForeColor="Red" runat="server" text="" />
            </div>
            <div style="float:right; padding-top:8px;">
              <div style="display:inline-block; margin-right:4px;"><telerik:RadButton ButtonType="SkinnedButton" ID="btnUser_Save" OnClientClicking="btnUser_Save_ClientClicking" OnClick="btnUser_Save_Click" runat="server" Text="Save" Width="100px"></telerik:RadButton></div>
              <div style="display:inline-block; margin-right:4px;"><telerik:RadButton AutoPostBack="false" ButtonType="SkinnedButton" ID="btnUser_Cancel" OnClientClicked="btnUser_Cancel_ClientClicked" runat="server" Text="Cancel" Width="100px"></telerik:RadButton></div>
            </div>
            <asp:HiddenField ID="hdnUser_Display" runat="server" value=""/>
          </asp:Panel>
        </ContentTemplate>
      </telerik:RadWindow>
    </Windows>
  </telerik:RadWindowManager>
 
  <telerik:RadScriptBlock id="contentScriptBlock" runat="server" >
    <script language="javascript" type="text/javascript">
      if (window.location == window.parent.location) {
        window.location.href = '<%= ResolveUrl("~/Shell.aspx") %>';
      }
 
      var msg = new Object;
      msg.pageNote = 'Administer Training Suite users . . .';
 
      function contentOnRequestStart(sender, args) {
        shell.BrowserWindow.loadingPanelON(500);
        var control = args.get_eventTargetElement();
        if (control) {
          switch (control.id) {
            case '<%= btnLookup_Search.ClientID %>':
              shell.BrowserWindow.loadingPanelOFF();
              break;
            case '<%= btnLookup_Insert.ClientID %>':
              shell.BrowserWindow.loadingPanelOFF();
              break;
            case '<%= btnUser_Load.ClientID %>':
              shell.BrowserWindow.loadingPanelOFF();
              break;
            case '<%= rdlUser_Crew.ClientID %>':
              shell.BrowserWindow.loadingPanelOFF();
              break;
            case '<%= btnUser_Save.ClientID %>':
              shell.BrowserWindow.loadingPanelOFF();
              break;
            default: break; //Do Nothing
          }
        }
      }
 
      function contentOnResponseEnd(sender, args) {
        shell.BrowserWindow.loadingPanelOFF();
        var control = args.get_eventTargetElement();
        if (control) {
          switch (control.id) {
            case '<%= btnLookup_Search.ClientID %>':
              var err = $get('<%= hdnError.ClientID %>');
              if (err.value !== '') {
                alert(err.value);
                err.value = '';
              }
              break;
            case '<%= btnLookup_Insert.ClientID %>':
              if ($get('<%= hdnUser.ClientID %>').value === '') {
                alert('User already exists in TrainingSuite (operation terminated).');
              } else {
                GetRadWindowManager().getWindowByName('winLookup').close();
                userEdit($get('<%= hdnUser.ClientID %>').value);
              }
              break;
            case '<%= btnUser_Load.ClientID %>':
              var radWindow = GetRadWindowManager().getWindowByName('winUser');
              radWindow.set_title('User Account Settings: ' + $('#<%= hdnUser_Display.ClientID %>').val());
              radWindow.set_status('User Profile Information');
              break;
            case '<%= btnUser_Save.ClientID %>':
              GetRadWindowManager().getWindowByName('winUser').close();
              $get('<%= hdnUser.ClientID %>').value = '';
              break;
            default: break; //Do Nothing
          }
        }
      }
 
      function userGrid_OnClientCommand(CommandName, CommandArgument) {
        var userGrid = $find('<%= userGrid.ClientID %>').get_masterTableView();
        var rows = userGrid.get_selectedItems();
        var postback = true
        switch (CommandName) {
          case 'addUser':
            GetRadWindowManager().getWindowByName('winLookup').show();
            postback = false;
            break;
          default:
            break;
        }
        return postback;
      }
 
      function userEdit(user) {
        $get('<%= hdnUser.ClientID %>').value = user;
        <% if ( ((User)Session["User"]).Roles(RoleComparison.HasNone, Role.SuperAdmin) ) { %>
        if (user != '<%= ((User)Session["User"]).UserID.ToString() %>') {
          GetRadWindowManager().getWindowByName('winUser').show();
        } else {
          alert('Editing you own account is prohibited. Please\ncontact an administrator to make the changes.');
        }
        <% } else { %>
        GetRadWindowManager().getWindowByName('winUser').show();
        <% } %>
      }
 
 
 
      function winLookup_OnClientShow(radWindow) {
        radWindow.set_status('Lookup users via Active Directory . . .');
        $find('<%= btnLookup_Search.ClientID %>').focus();
      }
 
      function winLookup_OnClientClose(sender, eventArgs) {
        $find('<%= txtLookup_LastName.ClientID %>').set_value('');
        $find('<%= txtLookup_FirstName.ClientID %>').set_value('');
        $find('<%= txtLookup_UserName.ClientID %>').set_value('');
        $('#<%= chkLookup_IncludeDisabled.ClientID %>').prop('checked', false);
        $find('<%= rlbLookup.ClientID %>').get_items().clear();
      }
 
      function btnLookup_Search_ClientClicking(sender, eventArgs) {
        if ($.trim($find('<%= txtLookup_LastName.ClientID %>').get_value()) === '' &&
            $.trim($find('<%= txtLookup_FirstName.ClientID %>').get_value()) === '' &&
            $.trim($find('<%= txtLookup_UserName.ClientID %>').get_value()) === '') {
          alert('Please fill in at least one search criteria field!');
          eventArgs.set_cancel(true);
        }
      }
 
      function btnLookup_Insert_ClientClicking(sender, eventArgs) {
        if ($find('<%= rlbLookup.ClientID %>').get_selectedItems().length === 0) {
          alert('No user has been selected yet!');
          eventArgs.set_cancel(true);
        }
      }
 
 
 
      function winUser_OnClientShow(radWindow) {
        $find('<%= btnUser_Load.ClientID %>').click();
      }
 
      function winUser_OnClientClose(sender, eventArgs) {
        var radWindow = GetRadWindowManager().getWindowByName('winUser');
        radWindow.set_title('User Account Settings');
        radWindow.set_status('User Profile Information');
        $find('<%= tabConfig.ClientID %>').findTabByValue('1').select();
        $find('<%= txtUser_LastName.ClientID %>').set_value('');
        $find('<%= txtUser_FirstName.ClientID %>').set_value('');
        $find('<%= txtUser_UserName.ClientID %>').set_value('');
        $find('<%= txtUser_EmployeeID.ClientID %>').set_value('');
        $get('<%= chkUser_Active.ClientID %>').checked = false;
        $find('<%= rdlUser_Site.ClientID %>').get_items().getItem(0).set_selected(true);
        $get('<%= hdnUser_Display.ClientID %>').value = '';
        $get('<%= hdnUser.ClientID %>').value = '';
        $get('<%= lblUser_Notice.ClientID %>').innerHTML = '';
        $find('<%= userGrid.ClientID %>').get_masterTableView().rebind();
      }
 
      function btnUser_Save_ClientClicking(sender, eventArgs) {
        var Halt = false;
        var last = $find('<%= txtUser_LastName.ClientID %>');
        if (!Halt && $.trim(last.get_value()) == '') {
          alert('User must be assigned a last name in order to save.');
          $find('<%= tabConfig.ClientID %>').findTabByValue('1').select();
          last.set_value('');
          last.focus();
          Halt = true;
        }
 
        var first = $find('<%= txtUser_FirstName.ClientID %>');
        if (!Halt && $.trim(first.get_value()) == '') {
          alert('User must be assigned a first name in order to save.');
          $find('<%= tabConfig.ClientID %>').findTabByValue('1').select();
          first.set_value('');
          first.focus();
          Halt = true;
        }
 
        var site = $find('<%= rdlUser_Site.ClientID %>');
        if (!Halt && site.get_selectedItem().get_value() == -1) {
          alert('User must be assigned a site in order to save.');
          $find('<%= tabConfig.ClientID %>').findTabByValue('1').select();
          site._element.focus();
          site.openDropDown();
          Halt = true;
        }
 
        if (Halt) {
          eventArgs.set_cancel(true);
        }
      }
 
      function btnUser_Cancel_ClientClicked(sender, eventArgs) {
        GetRadWindowManager().getWindowByName('winUser').close();
      }
 
 
 
      function tabConfig_ClientTabSelected(sender, eventArgs) {
        var status = '';
        switch (eventArgs.get_tab().get_value()) {
          case '1':
            status = 'User Profile Information';
            break;
          case '2':
            status = 'Security Roles Settings';
            break;
          case '3':
            status = 'Specific "Ops Training Performance" Module Settings';
            break;
          case '4':
            status = 'Specific "L . A . S . E . R ." Module Settings';
            break;
          case '5':
            status = 'Specific "Instructor Evals" Module Settings';
            break;
          case '6':
            status = 'Specific "Trainging Requests" Module Settings';
            break;
        }
        GetRadWindowManager().getWindowByName('winUser').set_status(status);
      }
 
 
 
      function pageLoad(sender, e) {
      //Auto-focus the lastname search field
        $find('<%= txtSearch_LastName.ClientID %>').focus();
 
      //Fix jumpy grid pager, so it smoothly moves on resize
        $(window).resize(function () {
          var grid = $find('<%= userGrid.ClientID %>');
          if (grid) {
            grid.repaint();
          }
        });
 
        if (!e.get_isPartialLoad()) {
          if (shell) {
            shell.BrowserWindow.winShell_Active();
            shell.BrowserWindow.winShell_SetStatus(msg.pageNote);
          }
        }
 
        var masterEl = $find('<%= userGrid.ClientID %>').get_masterTableView().get_element();
        var noItemsEl = $(masterEl).find(".rgNoRecords")[0];
        if (noItemsEl) {
          masterEl.style.height = '75%';
          masterEl.style.width = '100%';
          $(masterEl).find('.rgNoRecords').children()[0].style.textAlign = 'center';
        }
 
      }
 
    </script>
  </telerik:RadScriptBlock>
 
  <asp:Panel DefaultButton="btnSearch" ID="searchPanel" runat="server">
    <div style="margin:8px 16px 0px 16px;">
      <fieldset style="padding-left:8px; height:95%; text-align:center;">
        <legend>Personnel Filter</legend>
        <div style="display:inline-block;">
          <div style="float:left; padding:4px 0px 8px 12px;">
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">Last Name:</span></div><telerik:RadTextBox ID="txtSearch_LastName" runat="server"></telerik:RadTextBox></div>
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">First Name:</span></div><telerik:RadTextBox ID="txtSearch_FirstName" runat="server"></telerik:RadTextBox></div>
          </div>
          <div style="float:left; padding:4px 0px 8px 12px;">
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">User Name:</span></div><telerik:RadTextBox ID="txtSearch_UserName" runat="server" Width="150px"></telerik:RadTextBox></div>
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">Employee ID:</span></div><telerik:RadTextBox ID="txtSearch_EmployeeID" runat="server" Width="150px"></telerik:RadTextBox></div>
          </div>
          <div style="float:left; padding:4px 0px 8px 12px;">
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:40px;"><span style="position:relative; top:2px;">Active:</span></div><telerik:RadDropDownList ID="rdlSearch_Active" runat="server" Width="180px"></telerik:RadDropDownList></div>
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:40px;"><span style="position:relative; top:2px;">Site:</span></div><telerik:RadDropDownList AutoPostBack="true" ID="rdlSearch_Site" OnSelectedIndexChanged="rdlSearch_Site_SelectedIndexChanged" runat="server" Width="180px"></telerik:RadDropDownList></div>
          </div>
          <div style="float:left; padding:4px 0px 8px 12px;">
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">Crew:</span></div><telerik:RadDropDownList AutoPostBack="true" ID="rdlSearch_Crew" OnSelectedIndexChanged="rdlSearch_Crew_SelectedIndexChanged" runat="server" Width="180px"></telerik:RadDropDownList></div>
            <div><div style="display:inline-block; padding-right:4px; text-align:right; width:70px;"><span style="position:relative; top:2px;">Crew Group:</span></div><telerik:RadDropDownList ID="rdlSearch_CrewGroup" runat="server" Width="180px"></telerik:RadDropDownList></div>
          </div>
        </div>
        <div style="clear:both;"></div>
        <div style="display:inline-block; padding:8px 0px 16px 0px;"><telerik:RadButton ButtonType="SkinnedButton" ID="btnSearch" OnClick="btnSearch_Click" runat="server" Text="Search" Width="100px"></telerik:RadButton></div>
      </fieldset>
    </div>
  </asp:Panel>
 
  <div style="height:70%; padding:8px 16px 0px 16px;">
    <telerik:RadGrid  AutoGenerateColumns="false" Height="100%" ID="userGrid" OnItemDataBound="userGrid_ItemDataBound" OnItemCommand="userGrid_ItemCommand" OnNeedDataSource="userGrid_NeedDataSource" runat="server" >
 
      <ClientSettings>
        <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
      </ClientSettings>
 
      <MasterTableView AllowPaging="true" AllowSorting="true" CommandItemDisplay="Top" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true" TableLayout="Fixed" Width="100%">
 
        <CommandItemTemplate>
          <div style="float:left; padding:4px;">
            <asp:LinkButton ID="btnAddRecord" CommandName="addUser" OnClientClick="return userGrid_OnClientCommand('addUser','')" runat="server"><img style="border:0px;vertical-align:middle;" alt="Add New User" src="../img/ico/addUSer.png"/><span style="left:4px;position:relative;top:2px;">Add User</span></asp:LinkButton>
          </div>
          <div style="float:right; padding:4px;">
          </div>
          <div style="clear:both;"></div>
        </CommandItemTemplate>
         
        <Columns>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="LastName" HeaderText="Last Name" UniqueName="LastName">
            <HeaderStyle Width="150px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="FirstName" HeaderText="First Name" UniqueName="FirstName">
            <HeaderStyle Width="150px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="UserName" HeaderText="User Name" UniqueName="UserName"
            <HeaderStyle Width="100px" />       
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="EmployeeID" HeaderText="Employee ID" UniqueName="EmployeeID">
            <HeaderStyle Width="100px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="Site" HeaderText="Site" UniqueName="Site">
            <HeaderStyle Width="125px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="Crew" HeaderText="Crew" UniqueName="Crew">
            <HeaderStyle Width="100px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="CrewGroup" HeaderText="Crew Group" UniqueName="CrewGroup">
            <HeaderStyle Width="100px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="Position" HeaderText="Position" UniqueName="Position">
            <HeaderStyle Width="100px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridBoundColumn AllowSorting="true" ColumnEditorID="User_ID" DataField="Qualifications" HeaderText="Qualifications" UniqueName="Qualifications">
            <HeaderStyle Width="100px" />
          </telerik:GridBoundColumn>
 
          <telerik:GridTemplateColumn ColumnEditorID="User_ID" DataField="Deleted" HeaderText="Active" SortExpression="Deleted" UniqueName="Deleted">
            <HeaderStyle Width="75px" HorizontalAlign="Center" />
            <ItemStyle HorizontalAlign="Center" />
            <ItemTemplate>
              <asp:Literal runat="server" ID="ltrActive" Text=<%# (Eval("Deleted").ToString() == "1") ? "No" : "Yes" %> ></asp:Literal>
            </ItemTemplate>
          </telerik:GridTemplateColumn>
 
          <telerik:GridTemplateColumn HeaderText="Action">
            <HeaderStyle Width="75px" HorizontalAlign="Center" />
            <ItemStyle HorizontalAlign="Center" />
            <ItemTemplate>
              <div>
                <asp:ImageButton ID="btnKey" ImageUrl="../img/edit.gif" OnClientClick=<%# Eval("User_ID", "userEdit('{0}'); return false;") %> runat="server" title="Edit User Account"/>
              </div>
            </ItemTemplate>
          </telerik:GridTemplateColumn>
 
          <telerik:GridTemplateColumn>
            <HeaderStyle Width="100%" />
          </telerik:GridTemplateColumn>
 
        </Columns>
 
        <NoRecordsTemplate>
          <asp:Label ID="lblEmpty" Font-Size="14pt" runat="server"  Text="SET FILTER AND CLICK SEARCH TO VIEW RECORDS"></asp:Label>
        </NoRecordsTemplate>
 
        <PagerStyle AlwaysVisible="true" />
      </MasterTableView>
 
    </telerik:RadGrid>
 
  </div>
   
</asp:Content>



CODE
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using Telerik.Web.UI;
 
public partial class Personnel : System.Web.UI.Page {
 
//Weird Issue with personnel.designer.cs not declaring these controls
  protected global::System.Web.UI.WebControls.CheckBox chkUser_AccessILT;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_AccessLORT;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_AccessNLORT;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_Active;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_Clerical;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_CorporateAdmin;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_CorporateOTM;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_CorporateTrainingManager;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_Evaluator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_ILTEvaluator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_ILTInstructor;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_ILTOperator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_InstructorEvaluator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_Licensed;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_LORTEvaluator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_LORTInstructor;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_LORTOperator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_NLORTEvaluator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_NLORTInstructor;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_NLORTOperator;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_OPSPeers;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_OPSTrainingInstructor;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_QALShiftManager;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_QALShiftTechnicalAdvisor;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_ShiftManager;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_SiteAdmin;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_SiteOPSManager;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_SiteOPSManagement;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_SiteOTM;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_SiteTrainingManager;
  protected global::System.Web.UI.WebControls.CheckBox chkUser_TrainingInstructorSME;
  protected global::System.Web.UI.WebControls.HiddenField hdnError;
  protected global::System.Web.UI.WebControls.HiddenField hdnUser;
  protected global::System.Web.UI.WebControls.HiddenField hdnUser_Display;
  protected global::System.Web.UI.WebControls.Label lblUser_Notice;
  protected global::Telerik.Web.UI.RadDropDownList rdlSearch_Active;
  protected global::Telerik.Web.UI.RadDropDownList rdlSearch_Site;
  protected global::Telerik.Web.UI.RadDropDownList rdlSearch_Crew;
  protected global::Telerik.Web.UI.RadDropDownList rdlSearch_CrewGroup;
  protected global::Telerik.Web.UI.RadDropDownList rdlUser_Crew;
  protected global::Telerik.Web.UI.RadDropDownList rdlUser_CrewGroup;
  protected global::Telerik.Web.UI.RadDropDownList rdlUser_Position;
  protected global::Telerik.Web.UI.RadDropDownList rdlUser_Site;
  protected global::Telerik.Web.UI.RadPageView rpvUserSecurity;
  protected global::Telerik.Web.UI.RadPageView rpvModOpsTrainingPerformance;
  protected global::Telerik.Web.UI.RadTextBox txtSearch_EmployeeID;
  protected global::Telerik.Web.UI.RadTextBox txtSearch_FirstName;
  protected global::Telerik.Web.UI.RadTextBox txtSearch_LastName;
  protected global::Telerik.Web.UI.RadTextBox txtSearch_UserName;
  protected global::Telerik.Web.UI.RadTextBox txtUser_EmployeeID;
  protected global::Telerik.Web.UI.RadTextBox txtUser_FirstName;
  protected global::Telerik.Web.UI.RadTextBox txtUser_LastName;
  protected global::Telerik.Web.UI.RadTextBox txtUser_UserName;
  protected global::Telerik.Web.UI.RadGrid userGrid;
 
  protected void Page_Load(object sender, EventArgs e) {
    ((Label)Page.Master.FindControl("lblHeader")).Text = "Personnel Admin";
    Session["NavURL"] = Request.Url.PathAndQuery;
    if (Session["User"] == null) {
      Response.Redirect("~/Login.aspx");
    }
    if (!Page.IsPostBack) {
      checkSecurity();
      rdlSearch_Active_Bind();
      rdlSearch_Site_Bind();
      rdlSearch_Crew_Bind();
      rdlSearch_CrewGroup_Bind();
      userGrid.DataSource = new int[] { };
      rdlUser_Site_Bind();
      rpvUserSecurity_Bind();
      rvpModOpsTrainingPerformance_Bind();
    }
  }
 
  /// <summary>
  /// Security check for this page. If the user does not have sufficient previlage, he/she is redirected to another page
  /// </summary>
  private void checkSecurity() {
    User usr = (User)Session["User"];
    // checks whether user is in any of the roles that has access to this page, and kick them out if they are not in any of these roles
    if (usr.Roles(RoleComparison.HasNone, Role.OPSTrainingInstructor | Role.Clerical | Role.SiteOTM | Role.SiteAdmin | Role.CorperateAdmin | Role.SuperAdmin)) {
      Response.Redirect("~/Home.aspx");
    }
  }
 
  protected void Page_PreRender(object sender, EventArgs e) {
    ((Literal)Page.Master.FindControl("ltrModule")).Text = "";
  }
 
  protected void btnSearch_Click(object sender, EventArgs e) {
    userGrid.Rebind();
    if (Convert.ToInt32(ViewState["RowCount"]) == 0) {
      GridNoRecordsItem norecordItem = (GridNoRecordsItem)userGrid.MasterTableView.GetItems(GridItemType.NoRecordsItem)[0];
      Label lbl = (Label)norecordItem.FindControl("lblEmpty");
      lbl.Text = "NO RECORDS FOUND MATCHING FILTER";
    }
  }
 
  protected void userGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) {
   switch(e.CommandName) {
     case "addUser":
       break;
     default:
       break;
    }
    userGrid.Rebind();
  }
 
  protected void userGrid_ItemDataBound(object sender, GridItemEventArgs e) {
    if (e.Item is GridDataItem) {
      GridDataItem gdi = e.Item as GridDataItem;
      Literal ltr = gdi["Deleted"].FindControl("ltrActive") as Literal;
      if (ltr.Text.Equals("No", StringComparison.OrdinalIgnoreCase)) {
        gdi.ForeColor = System.Drawing.Color.Red;
      }
    }
  }
 
  protected void userGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) {
    DataSet ds = new DataSet();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ToString())) {
      con.Open();
      using (SqlCommand cmd = con.CreateCommand()) {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGBL_Users_Select";
        cmd.Parameters.Add("@LastName", SqlDbType.NVarChar, 255).Value = txtSearch_LastName.Text;
        cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 255).Value = txtSearch_FirstName.Text;
        cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 255).Value = txtSearch_UserName.Text;
        cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 255).Value = txtSearch_EmployeeID.Text;
        cmd.Parameters.Add("@Active", SqlDbType.Int).Value = Convert.ToInt32(rdlSearch_Active.SelectedValue);
        cmd.Parameters.Add("@Site", SqlDbType.Int).Value = Convert.ToInt32(rdlSearch_Site.SelectedValue);
        cmd.Parameters.Add("@Crew", SqlDbType.Int).Value = Convert.ToInt32(rdlSearch_Crew.SelectedValue);
        cmd.Parameters.Add("@CrewGroup", SqlDbType.Int).Value = Convert.ToInt32(rdlSearch_CrewGroup.SelectedValue);
        using (SqlDataAdapter adapter = new SqlDataAdapter(cmd)) {
          adapter.Fill(ds);
        }
      }
    }
    ViewState["RowCount"] = ds.Tables[0].Rows.Count;
    userGrid.DataSource = ds;
  }
 
  protected void btnLookup_Search_Click(object sender, EventArgs e) {
    rlbLookup.DataTextField = "adUser";
    rlbLookup.DataValueField = "adGUID";
    DataTable sql = Security.QueryActiveDirectoryUsers(txtLookup_LastName.Text, txtLookup_FirstName.Text, txtLookup_UserName.Text, chkLookup_IncludeDisabled.Checked);
    if (sql.Rows[0]["adGUID"].ToString().Equals("-1")) {
      rlbLookup.Items.Clear();
      hdnError.Value = sql.Rows[0]["adUser"].ToString(); //Will contain the returned error message
    } else {
      rlbLookup.DataSource = sql;
      rlbLookup.DataBind();
    }
  }
 
  protected void btnLookup_Insert_Click(object sender, EventArgs e) {
    try {
      using (UserPrincipal user = Security.GetActiveDirectoryUserInfo(new Guid(rlbLookup.SelectedValue))) {
        using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ToString())) {
          con.Open();
          using (SqlTransaction tra = con.BeginTransaction()) {
            using (SqlCommand cmd = con.CreateCommand()) {
              cmd.Transaction = tra;
 
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.CommandText = "spGBL_AD2TSMAP_Insert";
              cmd.Parameters.Add("@adGUID", SqlDbType.UniqueIdentifier).Value = user.Guid;
              Guid tsGUID = new Guid(cmd.ExecuteScalar().ToString());
 
              cmd.Parameters.Clear();
              cmd.CommandText = "spGBL_Users_Insert";
              cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = tsGUID;
              cmd.Parameters.Add("@LastName", SqlDbType.NVarChar, 0).Value = user.Surname;
              cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 0).Value = user.GivenName;
              cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 0).Value = user.SamAccountName;
              if (user.EmployeeId == null) { cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 0).Value = ""; } else { cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 0).Value = user.EmployeeId; }
              cmd.Parameters.Add("@Modified_By", SqlDbType.UniqueIdentifier, 0).Value = ((User)Session["User"]).UserID;
              cmd.ExecuteNonQuery();
 
              cmd.Parameters.Clear();
              cmd.CommandText = "spOTP_Users_Profile_Insert";
              cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = tsGUID;
              cmd.Parameters.Add("@Licensed", SqlDbType.Bit).Value = 0;
              cmd.Parameters.Add("@Crew_ID", SqlDbType.Int).Value = DBNull.Value;
              cmd.Parameters.Add("@CrewGroup_ID", SqlDbType.Int).Value = DBNull.Value;
              cmd.Parameters.Add("@Position_ID", SqlDbType.Int).Value = DBNull.Value;
              cmd.Parameters.Add("@Qualifications", SqlDbType.BigInt).Value = 0;
              cmd.Parameters.Add("@ILT_Positions", SqlDbType.BigInt).Value = 0;
              cmd.Parameters.Add("@LORT_Positions", SqlDbType.BigInt).Value = 0;
              cmd.Parameters.Add("@NLORT_Positions", SqlDbType.BigInt).Value = 0;
              cmd.Parameters.Add("@Modified_By", SqlDbType.UniqueIdentifier, 0).Value = ((User)Session["User"]).UserID;
              cmd.ExecuteNonQuery();
 
              hdnUser.Value = tsGUID.ToString();
               
              tra.Commit();
            }
          }
        }     
      }
    }
    catch (Exception ex) {
      hdnUser.Value = "";
    }
  }
 
  private DataTable getSiteData() {
    DataTable dat = new DataTable();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ConnectionString)) {
      con.Open();
      using (SqlCommand cmd = con.CreateCommand()) {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGBL_Sites_Select";
        if (((User)Session["User"]).Roles(RoleComparison.HasAny, Role.CorporateOTM | Role.CorporateTrainingManager | Role.CorperateAdmin | Role.SuperAdmin)) {
          cmd.Parameters.Add("@Include_Corporate", SqlDbType.Int).Value = 1;
        }
        using (SqlDataAdapter adp = new SqlDataAdapter(cmd)) {
          adp.Fill(dat);
        }
      }
    }
    return dat;
  }
 
  private DataTable getCrewData(Int32 Site_ID) {
    String x = Session["Site"].ToString();
    DataTable dat = new DataTable();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ConnectionString)) {
      con.Open();
      using (SqlCommand cmd = con.CreateCommand()) {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGBL_Crews_Select";
        cmd.Parameters.Add("@Site_ID", SqlDbType.Int).Value = Site_ID;
        cmd.Parameters.Add("@Department_Type_ID", SqlDbType.Int).Value = 1;
        using (SqlDataAdapter adp = new SqlDataAdapter(cmd)) {
          adp.Fill(dat);
        }
      }
    }
    return dat;
  }
 
  private DataTable getCrewGroupData(Int32 Site_ID, Int32 Crew_ID) {
    if (Crew_ID == 0) {
      Crew_ID = -1;
    }
    DataTable dat = new DataTable();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ConnectionString)) {
      con.Open();
      using (SqlCommand cmd = con.CreateCommand()) {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spOTP_CrewGroups_Select";
        cmd.Parameters.Add("@Site_ID", SqlDbType.Int).Value = Site_ID;
        cmd.Parameters.Add("@Crew_ID", SqlDbType.Int).Value = Crew_ID;
        using (SqlDataAdapter adp = new SqlDataAdapter(cmd)) {
          adp.Fill(dat);
        }
      }
    }
    return dat;
  }
 
  private DataTable getPositionData(Int32 Site_ID) {
    DataTable dat = new DataTable();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ConnectionString)) {
      con.Open();
      using (SqlCommand cmd = con.CreateCommand()) {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spOTP_Positions_Select";
        cmd.Parameters.Add("@Site_ID", SqlDbType.Int).Value = Site_ID;
        using (SqlDataAdapter adp = new SqlDataAdapter(cmd)) {
          adp.Fill(dat);
        }
      }
    }
    return dat;
  }
 
  private void rdlSearch_Active_Bind() {
    rdlSearch_Active.Items.Insert(0, new DropDownListItem("--ALL--", "0"));
    rdlSearch_Active.Items.Insert(1, new DropDownListItem("Yes", "1"));
    rdlSearch_Active.Items.Insert(2, new DropDownListItem("No", "2"));
    rdlSearch_Active.SelectedValue = "1";
  }
 
  private void rdlSearch_Site_Bind() {
    rdlSearch_Site.DataTextField = "Site";
    rdlSearch_Site.DataValueField = "Site_ID";
    DataTable sql = getSiteData();
    rdlSearch_Site.DataSource = sql;
    rdlSearch_Site.DataBind();
    rdlSearch_Site.Items.Insert(0, new DropDownListItem("--ALL--", "-1"));
    rdlSearch_Site.SelectedValue = Convert.ToString(Session["Site"]);
    User user = (User)Session["User"];
    if (user.Roles(RoleComparison.HasNone, Role.CorperateAdmin | Role.SuperAdmin)) {
      rdlSearch_Site.Enabled = false;
    }
  }
 
  private void rdlSearch_Crew_Bind() {
    rdlSearch_Crew.DataTextField = "Crew";
    rdlSearch_Crew.DataValueField = "Crew_ID";
    DataTable sql = getCrewData(Convert.ToInt32(rdlSearch_Site.SelectedValue));
    rdlSearch_Crew.DataSource = sql;
    rdlSearch_Crew.DataBind();
    rdlSearch_Crew.Items.Insert(0, new DropDownListItem("--ALL--", "-1"));
  }
 
  private void rdlSearch_CrewGroup_Bind() {
    rdlSearch_CrewGroup.DataTextField = "CrewGroup";
    rdlSearch_CrewGroup.DataValueField = "CrewGroup_ID";
    DataTable sql = getCrewGroupData(Convert.ToInt32(rdlSearch_Site.SelectedValue), Convert.ToInt32(rdlSearch_Crew.SelectedValue));
    rdlSearch_CrewGroup.DataSource = sql;
    rdlSearch_CrewGroup.DataBind();
    rdlSearch_CrewGroup.Items.Insert(0, new DropDownListItem("--ALL--", "-1"));
  }
 
  private void rdlUser_Site_Bind() {
    rdlUser_Site.DataTextField = "Site";
    rdlUser_Site.DataValueField = "Site_ID";
    DataTable sql = getSiteData();
    rdlUser_Site.DataSource = sql;
    rdlUser_Site.DataBind();
    rdlUser_Site.Items.Insert(0, new DropDownListItem("-- SELECT A SITE --", "-1"));
  }
 
  private void rdlUser_Crew_Bind() {
    rdlUser_Crew.DataTextField = "Crew";
    rdlUser_Crew.DataValueField = "Crew_ID";
    DataTable sql = getCrewData(Convert.ToInt32(rdlUser_Site.SelectedValue));
    rdlUser_Crew.DataSource = sql;
    rdlUser_Crew.DataBind();
    rdlUser_Crew.Items.Insert(0, new DropDownListItem("N/A", "0"));
  }
 
 
  private void rdlUser_CrewGroup_Bind() {
    rdlUser_CrewGroup.DataTextField = "CrewGroup";
    rdlUser_CrewGroup.DataValueField = "CrewGroup_ID";
    DataTable sql = getCrewGroupData(Convert.ToInt32(rdlUser_Site.SelectedValue), Convert.ToInt32(rdlUser_Crew.SelectedValue));
    rdlUser_CrewGroup.DataSource = sql;
    rdlUser_CrewGroup.DataBind();
    rdlUser_CrewGroup.Items.Insert(0, new DropDownListItem("N/A", "0"));
  }
 
  private void rdlUser_Position_Bind() {
    rdlUser_Position.DataTextField = "Position";
    rdlUser_Position.DataValueField = "Position_ID";
    DataTable sql = getPositionData(Convert.ToInt32(rdlUser_Site.SelectedValue));
    rdlUser_Position.DataSource = sql;
    rdlUser_Position.DataBind();
    rdlUser_Position.Items.Insert(0, new DropDownListItem("N/A", "0"));
  }
 
  private void rpvUserSecurity_Bind() {
    chkUser_SiteAdmin.InputAttributes.Add("Value", "2");
    chkUser_CorporateAdmin.InputAttributes.Add("Value", "1");
 
    chkUser_OPSTrainingInstructor.InputAttributes.Add("Value", "14");
    chkUser_ShiftManager.InputAttributes.Add("Value", "13");
    chkUser_Evaluator.InputAttributes.Add("Value", "12");
    chkUser_SiteOPSManagement.InputAttributes.Add("Value", "11");
    chkUser_SiteOTM.InputAttributes.Add("Value", "10");
    chkUser_OPSPeers.InputAttributes.Add("Value", "9");
    chkUser_CorporateOTM.InputAttributes.Add("Value", "8");
    chkUser_Clerical.InputAttributes.Add("Value", "7");
 
    chkUser_InstructorEvaluator.InputAttributes.Add("Value", "6");
    chkUser_TrainingInstructorSME.InputAttributes.Add("Value", "5");
    chkUser_SiteTrainingManager.InputAttributes.Add("Value", "4");
    chkUser_CorporateTrainingManager.InputAttributes.Add("Value", "3");
  }
 
  private void rvpModOpsTrainingPerformance_Bind() {
    chkUser_AccessILT.InputAttributes.Add("Value", "1");
    chkUser_AccessLORT.InputAttributes.Add("Value", "2");
    chkUser_AccessNLORT.InputAttributes.Add("Value", "3");
 
    chkUser_QALShiftTechnicalAdvisor.InputAttributes.Add("Value", "1");
    chkUser_QALShiftManager.InputAttributes.Add("Value", "2");
 
    chkUser_ILTOperator.InputAttributes.Add("Value", "1");
    chkUser_ILTInstructor.InputAttributes.Add("Value", "2");
    chkUser_ILTEvaluator.InputAttributes.Add("Value", "4");
 
    chkUser_LORTOperator.InputAttributes.Add("Value", "1");
    chkUser_LORTInstructor.InputAttributes.Add("Value", "2");
    chkUser_LORTEvaluator.InputAttributes.Add("Value", "4");
 
    chkUser_NLORTOperator.InputAttributes.Add("Value", "1");
    chkUser_NLORTInstructor.InputAttributes.Add("Value", "2");
    chkUser_NLORTEvaluator.InputAttributes.Add("Value", "4");
  }
 
  protected void btnUser_Load_Click(object sender, EventArgs e) {
    DataTable Details = getUserDetails(new Guid(hdnUser.Value));
 
  //Notice
    hdnUser_Display.Value = String.Format("{0} ({1}, {2})", Details.Rows[0]["UserName"], Details.Rows[0]["LastName"], Details.Rows[0]["FirstName"]);
    lblUser_Notice.Text = "";
    if (!Security.CheckGroupMembership(new Guid(Convert.ToString(Details.Rows[0]["adGUID"])), ConfigurationManager.AppSettings["tsGroup"])) {
      lblUser_Notice.Text = String.Format(" * Not a member of: {0}! (Security Roles will not apply)", ConfigurationManager.AppSettings["tsGroup"]);
    }
 
  //Employee Info
    txtUser_LastName.Text = Convert.ToString(Details.Rows[0]["LastName"]);
    txtUser_FirstName.Text = Convert.ToString(Details.Rows[0]["FirstName"]);
    txtUser_UserName.Text = Convert.ToString(Details.Rows[0]["UserName"]);
    txtUser_EmployeeID.Text = Convert.ToString(Details.Rows[0]["EmployeeID"]);
    chkUser_Active.Checked = !Convert.ToBoolean(Convert.ToInt32(Details.Rows[0]["Deleted"]));
    rdlUser_Site.SelectedValue = Convert.ToString(Details.Rows[0]["Site_ID"]);
 
  //User Security
    chkUser_SiteAdmin.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.SiteAdmin) == Role.SiteAdmin);
    chkUser_CorporateAdmin.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.CorperateAdmin) == Role.CorperateAdmin);
 
    chkUser_OPSTrainingInstructor.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.OPSTrainingInstructor) == Role.OPSTrainingInstructor);
    chkUser_ShiftManager.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.ShiftManager) == Role.ShiftManager);
    chkUser_Evaluator.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.Evaluator) == Role.Evaluator);
    chkUser_SiteOPSManagement.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.SiteOPSManagement) == Role.SiteOPSManagement);
    chkUser_SiteOTM.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.SiteOTM) == Role.SiteOTM);
    chkUser_OPSPeers.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.OPSPeer) == Role.OPSPeer);
    chkUser_CorporateOTM.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.CorporateOTM) == Role.CorporateOTM);
    chkUser_Clerical.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.Clerical) == Role.Clerical);
 
    chkUser_InstructorEvaluator.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.InstructorEvaluator) == Role.InstructorEvaluator);
    chkUser_TrainingInstructorSME.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.TrainingInstructorSME) == Role.TrainingInstructorSME);
    chkUser_SiteTrainingManager.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.SiteTrainingManager) == Role.SiteTrainingManager);
    chkUser_CorporateTrainingManager.Checked = ((((Role)Convert.ToInt64(Details.Rows[0]["UserRoles"])) & Role.CorporateTrainingManager) == Role.CorporateTrainingManager);
 
  //OTP Training Performance
    chkUser_Licensed.Checked = Convert.ToBoolean(Convert.ToString(Details.Rows[0]["Licensed"]));
    chkUser_AccessILT.Checked = ((Convert.ToInt64(Details.Rows[0]["OTPUserRoles"]) & 2) == 2);
    chkUser_AccessLORT.Checked = ((Convert.ToInt64(Details.Rows[0]["OTPUserRoles"]) & 4) == 4);
    chkUser_AccessNLORT.Checked = ((Convert.ToInt64(Details.Rows[0]["OTPUserRoles"]) & 8) == 8);
 
    rdlUser_Crew_Bind();
    rdlUser_Crew.SelectedValue =  (Details.Rows[0]["Crew_ID"] == DBNull.Value) ? "0" : Convert.ToString(Details.Rows[0]["Crew_ID"]);
    rdlUser_CrewGroup_Bind();
    rdlUser_CrewGroup.SelectedValue = (Details.Rows[0]["CrewGroup_ID"] == DBNull.Value) ? "0" : Convert.ToString(Details.Rows[0]["CrewGroup_ID"]);
    rdlUser_Position_Bind();
    rdlUser_Position.SelectedValue = (Details.Rows[0]["Position_ID"] == DBNull.Value) ? "0" : Convert.ToString(Details.Rows[0]["Position_ID"]);
 
    chkUser_QALShiftTechnicalAdvisor.Checked = ((Convert.ToInt64(Details.Rows[0]["Qualifications"]) & 1) == 1);
    chkUser_QALShiftManager.Checked = ((Convert.ToInt64(Details.Rows[0]["Qualifications"]) & 2) == 2);
 
    chkUser_ILTOperator.Checked = ((Convert.ToInt64(Details.Rows[0]["ILT_Positions"]) & 1) == 1);
    chkUser_ILTInstructor.Checked = ((Convert.ToInt64(Details.Rows[0]["ILT_Positions"]) & 2) == 2);
    chkUser_ILTEvaluator.Checked = ((Convert.ToInt64(Details.Rows[0]["ILT_Positions"]) & 4) == 4);
      
    chkUser_LORTOperator.Checked = ((Convert.ToInt64(Details.Rows[0]["LORT_Positions"]) & 1) == 1);
    chkUser_LORTInstructor.Checked = ((Convert.ToInt64(Details.Rows[0]["LORT_Positions"]) & 2) == 2);
    chkUser_LORTEvaluator.Checked = ((Convert.ToInt64(Details.Rows[0]["LORT_Positions"]) & 4) == 4);
 
    chkUser_NLORTOperator.Checked = ((Convert.ToInt64(Details.Rows[0]["NLORT_Positions"]) & 1) == 1);
    chkUser_NLORTInstructor.Checked = ((Convert.ToInt64(Details.Rows[0]["NLORT_Positions"]) & 2) == 2);
    chkUser_NLORTEvaluator.Checked = ((Convert.ToInt64(Details.Rows[0]["NLORT_Positions"]) & 4) == 4);
  }
 
  protected void rdlSearch_Site_SelectedIndexChanged(object sender, DropDownListEventArgs e) {
    rdlSearch_Crew_Bind();
    rdlSearch_Crew.SelectedIndex = 0;
    rdlSearch_CrewGroup_Bind();
    rdlSearch_CrewGroup.SelectedIndex = 0;
  }
 
  protected void rdlSearch_Crew_SelectedIndexChanged(object sender, DropDownListEventArgs e) {
    rdlSearch_CrewGroup_Bind();
    rdlSearch_CrewGroup.SelectedIndex = 0;
  }
 
  protected void rdlUser_Site_SelectedIndexChanged(object sender, DropDownListEventArgs e) {
    rdlUser_Crew_Bind();
    rdlUser_Crew.SelectedIndex = 0;
    rdlUser_CrewGroup_Bind();
    rdlUser_CrewGroup.SelectedIndex = 0;
    rdlUser_Position_Bind();
    rdlUser_Position.SelectedIndex = 0;
  }
 
  protected void rdlUser_Crew_SelectedIndexChanged(object sender, DropDownListEventArgs e) {
    rdlUser_CrewGroup_Bind();
    rdlUser_CrewGroup.SelectedIndex = 0;
  }
 
  protected void btnUser_Save_Click(object sender, EventArgs e) {
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ToString())) {
      con.Open();
      using (SqlTransaction tra = con.BeginTransaction()) {
        using (SqlCommand cmd = con.CreateCommand()) {
          cmd.Transaction = tra;
 
          cmd.CommandType = CommandType.StoredProcedure;
 
        //Employee Info
          cmd.CommandText = "spGBL_Users_Update";
          cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = new Guid(hdnUser.Value);
          cmd.Parameters.Add("@LastName", SqlDbType.NVarChar, 255).Value = txtUser_LastName.Text;
          cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 255).Value = txtUser_FirstName.Text;
          cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 255).Value = txtUser_UserName.Text;
          cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 255).Value = txtUser_EmployeeID.Text;
          cmd.Parameters.Add("@Active", SqlDbType.Int).Value = Convert.ToInt32(!chkUser_Active.Checked);
          cmd.Parameters.Add("@Site", SqlDbType.Int).Value = Convert.ToInt32(rdlUser_Site.SelectedValue);
          cmd.Parameters.Add("@Modified_By", SqlDbType.UniqueIdentifier, 0).Value = ((User)Session["User"]).UserID;
          cmd.ExecuteNonQuery();
 
        //User Security
          foreach (Control ctr in rpvUserSecurity.Controls) {
            if (ctr is CheckBox && ctr != null) {
              CheckBox chk = (CheckBox)ctr;
              if (chk.Checked) {
                cmd.CommandText = "spGBL_UsersRoles_Insert";
              } else {
                cmd.CommandText = "spGBL_UsersRoles_Delete";
              }
              cmd.Parameters.Clear();
              cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = new Guid(hdnUser.Value);
              cmd.Parameters.Add("@Role_ID", SqlDbType.Int).Value = Convert.ToInt32(chk.InputAttributes["Value"]);
              cmd.Parameters.Add("@Modified_By", SqlDbType.UniqueIdentifier, 0).Value = ((User)Session["User"]).UserID;
              cmd.ExecuteNonQuery();
            }
          }
 
        //OTP Training Performance
          foreach (Control ctr in rpvModOpsTrainingPerformance.Controls) {
            if (ctr is CheckBox && ctr != null) {
              CheckBox chk = (CheckBox)ctr;
              if (chk.ID.StartsWith("chkUser_Access")) {
                if (chk.Checked) {
                  cmd.CommandText = "spOTP_UsersRoles_Insert";
                } else {
                  cmd.CommandText = "spOTP_UsersRoles_Delete";
                }
                cmd.Parameters.Clear();
                cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = new Guid(hdnUser.Value);
                cmd.Parameters.Add("@Role_ID", SqlDbType.Int).Value = Convert.ToInt32(chk.InputAttributes["Value"]);
                cmd.Parameters.Add("@Modified_By", SqlDbType.UniqueIdentifier, 0).Value = ((User)Session["User"]).UserID;
                cmd.ExecuteNonQuery();
              }
            }
          }
 
          Int64 QAL = 0;
          Int64 ILT = 0;
          Int64 LORT = 0;
          Int64 NLORT = 0;
          foreach (Control ctr in rpvModOpsTrainingPerformance.Controls) {
            if (ctr is CheckBox && ctr != null) {
              CheckBox chk = (CheckBox)ctr;
              if (chk.Checked) {
                if (chk.ID.StartsWith("chkUser_QAL")) {
                  QAL = (QAL | Convert.ToInt64(chk.InputAttributes["Value"]));
                }
                if (chk.ID.StartsWith("chkUser_ILT")) {
                  ILT = (ILT | Convert.ToInt64(chk.InputAttributes["Value"]));
                }
                if (chk.ID.StartsWith("chkUser_LORT")) {
                  LORT = (LORT | Convert.ToInt64(chk.InputAttributes["Value"]));
                }
                if (chk.ID.StartsWith("chkUser_NLORT")) {
                  NLORT = (NLORT | Convert.ToInt64(chk.InputAttributes["Value"]));
                }
              }
              cmd.CommandText = "spOTP_Users_Profile_Update";
              cmd.Parameters.Clear();
              cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = new Guid(hdnUser.Value);
              cmd.Parameters.Add("@Licensed", SqlDbType.Bit).Value = chkUser_Licensed.Checked;
              if (rdlUser_Crew.SelectedValue.Equals("0")) { cmd.Parameters.Add("@Crew_ID", SqlDbType.Int).Value = DBNull.Value; } else { cmd.Parameters.Add("@Crew_ID", SqlDbType.Int).Value = Convert.ToInt32(rdlUser_Crew.SelectedValue); }
              if (rdlUser_CrewGroup.SelectedValue.Equals("0")) { cmd.Parameters.Add("@CrewGroup_ID", SqlDbType.Int).Value = DBNull.Value; } else {cmd.Parameters.Add("@CrewGroup_ID", SqlDbType.Int).Value = Convert.ToInt32(rdlUser_CrewGroup.SelectedValue); }
              if (rdlUser_Position.SelectedValue.Equals("0")) { cmd.Parameters.Add("@Position_ID", SqlDbType.Int).Value = DBNull.Value; } else {cmd.Parameters.Add("@Position_ID", SqlDbType.Int).Value = Convert.ToInt32(rdlUser_Position.SelectedValue); }
              cmd.Parameters.Add("@Qualifications", SqlDbType.BigInt).Value = QAL;
              cmd.Parameters.Add("@ILT_Positions", SqlDbType.BigInt).Value = ILT;
              cmd.Parameters.Add("@LORT_Positions", SqlDbType.BigInt).Value = LORT;
              cmd.Parameters.Add("@NLORT_Positions", SqlDbType.BigInt).Value = NLORT;
              cmd.Parameters.Add("@Modified_By", SqlDbType.UniqueIdentifier, 0).Value = ((User)Session["User"]).UserID;
              cmd.ExecuteNonQuery();
            }
          }
 
          tra.Commit();
        }
      }
    }
 
    userGrid.Rebind();
  }
 
  private DataTable getUserDetails(Guid User_ID) {
    DataTable dat = new DataTable();
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TrainingSuite"].ToString())) {
      con.Open();
      using (SqlCommand cmd = con.CreateCommand()) {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spGBL_Users_SelectDetails";
        cmd.Parameters.Add("@User_ID", SqlDbType.UniqueIdentifier).Value = User_ID;
        using (SqlDataAdapter adapter = new SqlDataAdapter(cmd)) {
          adapter.Fill(dat);
        }
      }
    }
    return dat;
  }
 
  public String AccountStatus(String Enabled) {
    String Status = "<img src=\"../img/ico/disabled.png\" title=\"Account Disabled\" />";
    if (Convert.ToBoolean(Enabled)) {
      Status = "<img src=\"../img/ico/enabled.png\" title=\"Account Enabled\" />";
    }
    return Status;
  }
 
}

0
Milena
Telerik team
answered on 13 Sep 2013, 11:36 AM
Hello John,

I prepared a sample project using the declaration of RadGrid you are using in order to isolate the problem. However, I am not able to replicate the problem on it. Could you please modify the project to reproduce the issue and let me know what I am missing?

Regards,
Milena
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Xorcist
Top achievements
Rank 1
Milena
Telerik team
Share this question
or