title: Binding DropDownList SelectedValue to DataValueField for GridView Update
body: <p>Ok guys, so I read this:
  <a href="https://stackoverflow.com/questions/3474933/how-to-set-selectedvalue-of-dropdownlist-in-gridview-edittemplate">How to set SelectedValue of DropDownList in GridView EditTemplate</a></p>
  
  <p>and I'm having the same issue. However, I don't want to bind the selected value to the displayed text, but instead the values. They are different attributes selected from a SQLDataSource. Here is my DDL code with its SQLDataSource:</p>
  
  <pre><code>&lt;asp:DropDownList ID="FoodCodeDropDownList" runat="server"
       DataSourceID="Plant_Carton_Food_List"
       DataTextField="Food_Description"
       DataValueField="PlantMaterial_FoodID"
       SelectedValue='&lt;%# Bind("PlantMaterial_FoodID") %&gt;' &gt;
  &lt;/asp:DropDownList&gt;
  &lt;asp:SqlDataSource ID="Plant_Carton_Food_List" runat="server" 
       ConnectionString="&lt;%$ ConnectionStrings:OMSConnectionString %&gt;" 
       SelectCommand="SELECT   P.PlantMaterial_FoodID,
                 M.Material_SAP_Value + ' - ' + MD.SAP_Long_Description AS Food_Description 
            FROM Plant_Carton_Food AS P 
            LEFT OUTER JOIN Material_Descriptions AS MD 
                 ON P.PlantMaterial_FoodID = MD.Material_ID 
            LEFT OUTER JOIN Materials AS M 
                 ON P.PlantMaterial_FoodID = M.Material_ID"&gt;
   &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>Here is the (abridged) SQLDataSource of the GridView:</p>
  
  <pre><code>   &lt;asp:SqlDataSource ID="Plant_Carton_Table" runat="server" 
          OldValuesParameterFormatString="old_{0}"
          ConnectionString="&lt;%$ ConnectionStrings:DBConnectionString %&gt;" 
          OnInserting="Plant_Carton_Food_Table_Inserting"
          OnInserted="Plant_Carton_Food_Table_Inserted"
          InsertCommand="spPlantCartonInsert" InsertCommandType="StoredProcedure" 
          SelectCommand="spPlantCartonSelect" SelectCommandType="StoredProcedure" 
          UpdateCommand="spPlantCartonUpdate" UpdateCommandType="StoredProcedure"&gt;
          &lt;UpdateParameters&gt;
              &lt;asp:Parameter Name="Active_Case"           Type="Boolean" /&gt;
              &lt;asp:Parameter Name="PlantMaterial_FoodID"  Type="String" /&gt;
              &lt;asp:Parameter Name="PlantMaterial_CaseID"  Type="String" /&gt;
              ...
          &lt;/UpdateParameters&gt;
          ...
      &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>And, finally, my exception:</p>
  
  <blockquote>
    <p>DataBinding: 'System.Data.DataRowView'
    does not contain a property with the
    name 'PlantMaterial_FoodID'.</p>
  </blockquote>
  
  <p>I really don't have much knowledge on how databinding through the GridView Edit templates work, but I was able to see that the correct values pass through the OnRowCommand event handler for updates. How do I propagate these values to the SQLDataSource without getting NULL?</p>
  
  <p>Right now, I guess any explanation on how databinding with GridView templates work in general would be beneficial as well. Thanks!</p>