title: Display Dropdown When Editing GridView
body: <p>I would like to display a field in my GridView as a DropDownList when a user is editing the row. The DropDownList would be pre-populated with two values, "Yes" and "No", and depending on which value a user selects I would like to set a variable.</p>
  
  <p>Example:</p>
  
  <p>I have a field called active. 1 = Active, 0 = Not Active. Although for the user I would like them to either set Active as "Yes" (1) or "No" (0). When when editing a row they could either choose "Yes" or "No" from the drop down and it would set a variable to either 1 or 0, so I can send that back in the SQL update. </p>
  
  <p>I found this <a href="http://msdn.microsoft.com/en-us/library/ms178294%28v=vs.80%29.aspx" rel="nofollow">MSDN article</a>.</p>
  
  <p>but it only tells me how to populate the DropDownList from a DataSource, which won't work for me since every field has either a yes or no for active. Also it displays a drop down even when just viewing the GridView, not just when editing. </p>
  
  <p>I hope that makes sense, thanks for the help.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is the code I have now, it almost works like I'd like it to. All I need to do now is change the label text to "Yes" if the value of Active is "True" and change the text to "No" if the value of Active is "False".  </p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Active" SortExpression="Active" &gt;
                          &lt;ItemTemplate&gt;
                               &lt;asp:Label ID="lblActive" runat="server" text='&lt;%# Eval("Active") %&gt;'/&gt;
                          &lt;/ItemTemplate&gt;
                          &lt;EditItemTemplate&gt;
                              &lt;asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='&lt;%# Bind("Active")  %&gt;'&gt;
                                  &lt;asp:ListItem Text="Yes" Value="True"&gt;&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Text="No" Value="False"&gt;&lt;/asp:ListItem&gt;
                              &lt;/asp:DropDownList&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
  </code></pre>