title: How to pre-select a value in RadioButtonList inside a GridView
body: <p>This might be a silly question but how can I preselect a <code>RadioButtonList</code> value based on existing data?</p>
  
  <p>I have this code inside the aspx file:</p>
  
  <pre><code>&lt;asp:TemplateField ItemStyle-CssClass="ItemCommand" &gt;
      &lt;HeaderTemplate&gt;&lt;/HeaderTemplate&gt;
      &lt;ItemTemplate&gt;
           &lt;asp:RadioButtonList runat="server" ID="rbLevel" RepeatLayout="Flow" RepeatDirection="Horizontal" &gt;
              &lt;asp:ListItem Text="Read" Value="0"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="Edit" Value="1"&gt;&lt;/asp:ListItem&gt;
          &lt;/asp:RadioButtonList&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>But I can't set the value of the list. <code>RadioButtonList</code> doesn't have a <code>SelectedValue</code> property, setting <code>DataValueField</code> has no effect and I can't set the values one by one (using something like:  <code>Selected='&lt;%# ((Rights)Container.DataItem).Level == 1  %&gt;'</code>) because databinding happens on the list not specific items.</p>