title: Issue setting checkboxes to disabled
body: <p>I am currently working on a project where the permissions of the site's users and their permissions are being displayed within a DevExpress GridView.  The user's permissions are simply checkboxes.  An issue I'm running across is setting the object for the checkbox.</p>
  
  <p>Originally, the site was used only by one entity (ie. office).  My goal is to make is used by multiple offices.  To accomplish this, I created a dropdown to switch between the offices so that you can set a user's permissions based on each office.  However, each office does not have the same list of permissions.</p>
  
  <p>Ex. The first office has full access to the site (12 modules) (it was the original office).  The second office only has access to 5 modules on the site.  I created a method to take care of this issue that disables everything but the 5 modules for the second office.</p>
  
  <p>On development, what I created to handle this works.  However, when moved to our testing enviroment, it stopped working.  The issue I believe is there are two foreach loops used to create the checkbox field, along with the column data of the grid.  Below is what I have done to make my solution work.</p>
  
  <p>View</p>
  
  <pre><code>foreach (var item in Model.Applications)
          {
              settings.Columns.AddBand(bnd =&gt;
              {
                  bnd.Name = string.Format("{0}", item.Name);
                  bnd.Caption = item.Name + " Roles";
  
                  foreach (var subitem in item.Roles)
                  {
                      bnd.Columns.Add(col =&gt;
                      {
                          col.Name = string.Format("{0}", subitem.Name);
                          col.FieldName = subitem.Name;
                          col.VisibleIndex = index;
                          col.Width = Unit.Pixel(75);
                          col.ColumnType = MVCxGridViewColumnType.CheckBox;
                          col.Caption = subitem.Description;
                          col.Settings.AllowAutoFilter = DefaultBoolean.False;
                          col.Settings.AllowHeaderFilter = DefaultBoolean.False;
                          col.Settings.AllowSort = DefaultBoolean.False;
  
                          col.SetDataItemTemplateContent(temp =&gt;
                          {
                          %&gt;
                          &lt;%=Html.CheckBox(
                                  string.Format("chk{0}{1}", col.Name, temp.KeyValue.ToString().Replace("-", "")),
                                  (bool)DataBinder.Eval(temp.DataItem, col.Name),
                                  SCCView.Areas.Admin.Models.ModifyPrivilegeModel.GetHtmlAttributes(bnd.Name, temp.KeyValue, col.Name, item.Name)
                                  )%&gt;
                          &lt;%
                          });
                      });
                      index++;
                  }
              });
          }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>public static object GetHtmlAttributes(string bndName, object keyValue, string colName, string itemName)
          {
              //Check to see if SCNGO is being used
              if (HttpContext.Current.Session["SCNGOAllowedApps"] != null)
              {
                  //Check to see if that Application is within SCNGO currently
                  var scngoApps = (List&lt;string&gt;)HttpContext.Current.Session["SCNGOAllowedApps"];
                  var app = scngoApps.Where(scngo =&gt; scngo == itemName).Select(scngo =&gt; scngo).FirstOrDefault();
  
                  //App is not, so disable it
                  if (app == null)
                      return new
                      {
                          onClick = string.Format(@"CheckChanged(this, '{0}', '{1}', '{2}');",
                                         bndName,
                                         keyValue,
                                         colName),
                          Class = "ModifyPrivChkBox",
                          disabled = "disabled"
                      };
              }
  
              //SCC, or at the very least an app within SCNGO
              return new
              {
                  onClick = string.Format(@"CheckChanged(this, '{0}', '{1}', '{2}');",
                                          bndName,
                                          keyValue,
                                          colName),
                  Class = "ModifyPrivChkBox"
              };
          }
  </code></pre>
  
  <p>On development, the checkboxes are disabled.  On our test site, they are not.  I have looked to see if the Session I used to do this is there or not and it is.  The issue is timing I believe.  The app variable I created always ends up with the last entry in the list, thus always allowing the checkbox to not be disabled.</p>
  
  <p>My question is is there a way to deal with this timing issue and make this more efficient?</p>