title: How can I change the output of a label, based on what's selected from a dropdown list (C# in ASP.NET)
body: <p>What I want to happen is to create a statement that describes the type of work the user selects in the second dropdown list (titled workList). When the user selects one of the options from the dropdown list, I want a short text description of that work to appear where the label below it is (titled lblWork). I only have one option in the event (workListChanged) right now. Once I figure out how to make THAT display, I should be able to finish the rest. But I can't figure out how to get the label to display something based on the selection. The error I'm currently receiving is "cannot implicity convert type 'string' to 'bool' in the "if" statement in the workListChanged event.</p>
  
  <pre><code>&lt;%@ Page Language="C#" Debug="true" %&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;script runat="server"&gt; 
  
  protected void workListChanged(object sender, EventArgs e)  
  {  
      if (workList.SelectedItem.Text = "Office Work")
          lblWork.Text = "You prefer to stay inside and code your life away.";
  }  
  &lt;/script&gt;
  
  &lt;html&gt;
  &lt;head id="Head1" runat="server"&gt;
      &lt;title&gt;Personality Test&lt;/title&gt;
      &lt;style&gt;
          ul {
              list-style-type: none;
  
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
           &lt;asp:Label id="lblName"
              Text="Name"
              AssociatedControlID="txtName"
              runat="server" /&gt;
  
          &lt;asp:TextBox
               id="txtname"
              AutoPostBack="true"
              runat="server" /&gt;
  
          &lt;br /&gt;&lt;br /&gt;
  
          &lt;asp:TextBox
              id="textComments"
              Text="Tell me a little about yourself"
              TextMode="MultiLine"
              Columns="30"
              rows="10"
              runat="server" /&gt;
          &lt;br /&gt;&lt;br /&gt;
  
          Select a gender:
          &lt;asp:RadioButton
              id="rd1Male"
              Text="Male"
              GroupName="rgGender"
              runat="server" /&gt;
  
          &lt;asp:RadioButton
              id="rd1Female"
              Text="Female"
              GroupName="rgGender"
             runat="server" /&gt;
          &lt;br /&gt;&lt;br /&gt;
  
  
          &lt;strong&gt;Favorite Season:&lt;/strong&gt;
          &lt;br /&gt;
           &lt;asp:DropDownList
               id="DropDownList1"
               Runat="server"
               AutoPostBack="true"
               &gt;
          &lt;asp:ListItem Text="Spring" /&gt;
          &lt;asp:ListItem Text="Summer" /&gt;
          &lt;asp:ListItem Text="Autumn" /&gt;
          &lt;asp:ListItem Text="Winter" /&gt;
          &lt;/asp:DropDownList&gt;
          &lt;br /&gt;&lt;br /&gt;
  
  
          &lt;strong&gt;Which of the following colors are your favorite?&lt;/strong&gt;
          &lt;ul&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Red"
                  Text="Red"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Blue"
                  Text="Blue"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Purple"
                  Text="Purple"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Yellow"
                  Text="Yellow"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Green"
                  Text="Green"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Orange"
                  Text="Orange"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Violet"
                  Text="Violet"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Pink"
                  Text="Pink"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="rd1Brown"
                  Text="Brown"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;asp:RadioButton
                  id="d1Grey"
                  Text="Grey"
                  GroupName="colors"
                  runat="server" /&gt;
              &lt;/li&gt;
          &lt;/ul&gt;        
          &lt;br /&gt;&lt;br /&gt;
          &lt;strong&gt;Which type of work do you prefer?&lt;/strong&gt;
          &lt;br /&gt;
            &lt;asp:DropDownList
               id="workList"
               Runat="server"
               AutoPostBack="true"
               OnSelectedIndexChanged="workListChanged"&gt;
          &lt;asp:ListItem Text="Office Work" /&gt;
          &lt;asp:ListItem Text="Outdoor Work" /&gt;
          &lt;asp:ListItem Text="Investigative Work" /&gt;
          &lt;asp:ListItem Text="Working With People" /&gt;
          &lt;asp:ListItem Text="Work Requiring Travel" /&gt;
          &lt;asp:ListItem Text="Helping People" /&gt;
          &lt;/asp:DropDownList&gt;
          &lt;br /&gt;
  
          &lt;asp:Label
              id="lblWork"
              runat ="server" /&gt;
  
  
  
  
  
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>