title: setting selected option in asp.net using c#
body: <p>I have a following code in aspx page</p>
  
  <pre><code>&lt;asp:DropDownList ID="txtSupplierCountry" class="form-control" Width="230px" runat="server"&gt;
                      &lt;asp:ListItem Text="Select gender" Value="0"&gt;&lt;/asp:ListItem&gt;
                      &lt;asp:ListItem Text="male" Value="0"&gt;&lt;/asp:ListItem&gt;
                      &lt;asp:ListItem Text="female" Value="1"&gt;&lt;/asp:ListItem&gt;
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>I have a value in database as male/female. I need to set this text using C# code. Basically I am trying to set selected option based on the text from database. I am not getting an idea. I have tried following code but it doesn't work.</p>
  
  <pre><code>String t = "male" // coming from db
  txtSupplierCountry.Items.FindByText(t).Selected = true;
  </code></pre>