title: ASP.NET CheckBoxList DataBinding Question
body: <p>Is it possible to DataBind an ASP.NET CheckBoxList such that a string value in the data becomes the label of the check box and a bool value checks/unchecks the box?</p>
  
  <p>On my asp.net webform I have a CheckBoxList like this:</p>
  
  <pre><code>&lt;asp:CheckBoxList runat="server" ID="chkListRoles" DataTextField="UserName" DataValueField="InRole" /&gt;
  </code></pre>
  
  <p>In the code behind I have this code:</p>
  
  <pre><code>var usersInRole = new List&lt;UserInRole&gt; 
  { 
    new UserInRole { UserName = "Frank", InRole = false},
    new UserInRole{UserName = "Linda", InRole = true},
    new UserInRole{UserName = "James", InRole = true},
  };
  
  chkListRoles.DataSource = usersInRole;
  chkListRoles.DataBind();
  </code></pre>
  
  <p>I was kinda hoping that the check boxes would be checked when InRole = true. I've also tried InRole = "Checked". The results were the same. I can't seem to find a way to DataBind and automagically have the check boxes checked/unchecked. </p>
  
  <p>Currently I solve the problem by setting selected = true for the appropriate items in the DataBound event. Seems like there's a cleaner solution just beyond my grasp.</p>
  
  <p>Thank You</p>