title: DropDownList, getting DataValueField returned in C#
body: <p>I have a drop down list that pulls data from a database to show some of its options:</p>
  
  <pre><code>    &lt;asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource1"
          DataTextField="Name" DataValueField="PK_Task" AppendDataBoundItems="true" CssClass="dropDownList"&gt;
          &lt;asp:ListItem Selected="True"&gt;General Support&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;Vacation&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;Sick Leave&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;Something Else&lt;/asp:ListItem&gt;
      &lt;/asp:DropDownList&gt;
      &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ApplicationServices %&gt;"
          SelectCommand="SELECT [PK_Task], [Name] FROM [Task] WHERE ([PointPerson] LIKE '%' + @PointPerson + '%') AND [Status] NOT LIKE 'Done'"&gt;
          &lt;SelectParameters&gt;
              &lt;asp:QueryStringParameter Name="PointPerson" Type="String" /&gt;
          &lt;/SelectParameters&gt;
      &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>As you can see, I only display the [Name] column: </p>
  
  <pre><code>DataTextField="Name" 
  </code></pre>
  
  <p>But I am also getting the primary key SELECT [PK_Task], [Name] FROM:</p>
  
  <pre><code>DataValueField="PK_Task"
  </code></pre>
  
  <p>How do I get access to this primary key based on user selection. If a user selects a specific 'name' from the drop down menu, what C# can I use to get the corresponding primary key returned to me so I can save it in a variable?</p>
  
  <p>The closest I have gotten is this, but all it does is return the string "PK_Task":</p>
  
  <pre><code>String taskID = DropDownList3.DataValueField;
  </code></pre>