title: bind radio button list to column in gridview
body: <p>I have radio button list in a gridview that needs to be bound to a column. If the value in a column is 0, the first radio button is selected, if 1, the other is selected. </p>
  
  <p>This is the code, some of it is partially removed because it is not necessary</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;&gt;"
      SelectCommand="" SelectCommandType="StoredProcedure" UpdateCommand=""&gt;
      &lt;SelectParameters&gt;&lt;/SelectParameters&gt;
      &lt;UpdateParameters&gt;&lt;/UpdateParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  &lt;asp:GridView ID="gvBlockDetail" runat="server" AutoGenerateColumns="False"
      DataKeyNames="curriculumyear,electiveid,blockid" DataSourceID="SqlDataSource1"
      HorizontalAlign="Left" CellPadding="1" CssClass="news" GridLines="None" 
      BorderColor="#ebe9e2" BorderStyle="Solid" BorderWidth="1" &gt;
      &lt;AlternatingRowStyle BackColor="#ebe9e2" /&gt;
      &lt;HeaderStyle BackColor="#660000" ForeColor="White" Font-Size="Small" /&gt;
      &lt;RowStyle Font-Size="9pt" Wrap="false" ForeColor="#660000" HorizontalAlign="Center" /&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="Add/Remove"&gt;
              &lt;HeaderStyle Width="15%" /&gt;
              &lt;ItemStyle Wrap="false" Width="80px" /&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:RadioButtonList ID="rblAddRemove" runat="server" RepeatDirection="Horizontal"&gt;
                      &lt;asp:ListItem Text="Add" Value="0"&gt;&lt;/asp:ListItem&gt;
                      &lt;asp:ListItem Text="Remove" Value="1"&gt;&lt;/asp:ListItem&gt;
                  &lt;/asp:RadioButtonList&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Block"&gt;
              &lt;HeaderStyle Width="15%" /&gt;
              &lt;ItemStyle Wrap="false" Width="50px"  /&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblBlock" runat="server" Text='&lt;%# Bind("Block") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;asp:Label ID="lblSection" runat="server" Text='&lt;%# Bind("Section") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="daterange" HeaderText="Dates" ReadOnly="True"  SortExpression="daterange" /&gt;
          &lt;asp:BoundField DataField="credithours" HeaderText="Credit Hrs" 
                                                      SortExpression="credithours" HeaderStyle-Width="10%" ItemStyle-Width="10%" /&gt;
          &lt;asp:TemplateField HeaderText="Students&amp;lt;br&amp;gt;Per Block" HeaderStyle-Width="15%" SortExpression="studentsperblock"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("studentsperblock") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/EditItemTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox ID="txtStudentsPerBlock" runat="server" MaxLength="3" Width="40px" Text='&lt;%# Bind("studentsperblock") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;    
          &lt;asp:BoundField DataField="enrolled" HeaderText="Enrolled" ReadOnly="True"
                                                      SortExpression="enrolled" ItemStyle-Width="200px" /&gt;  
          &lt;asp:BoundField DataField="blockid" HeaderText="blockid" ReadOnly="True" 
                                                      SortExpression="blockid" Visible="false" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Codebehind:</p>
  
  <pre><code>Protected Sub gvBlockDetail_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvBlockDetail.RowDataBound
  
  End Sub
  </code></pre>