title: Understanding ObjectDataSource and Select Parameters
body: <p>I have in a GridView control a TemplateField like:</p>
  
  <pre><code>&lt;asp:TemplateField ItemStyle-Width="150px"&gt;
     &lt;ItemTemplate&gt;
        &lt;asp:DropDownList ID="ddlFields" runat="server" DataSourceID="odsOperator" DataTextField="Text" DataValueField="Value" /&gt;
        &lt;asp:HiddenField ID="hfFieldType" runat="server" Value='&lt;%# Eval("FieldType")%&gt;' /&gt;
     &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>I have a dropdown that I want to populate from a ObjectDataSource, but for each line I want to pass a Select Parameter so it populates with the right values</p>
  
  <pre><code>&lt;asp:ObjectDataSource ID="odsOperator" runat="server" TypeName="OperatorFieldsDAO"
     SelectMethod="FindByType"&gt;      
     &lt;SelectParameters&gt;
        &lt;asp:ControlParameter ControlID="hfFieldType" Type="String" Name="Type" PropertyName="Value" /&gt;
     &lt;/SelectParameters&gt;
  &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <hr>
  
  <p>my OperatorFieldsDAO class is:</p>
  
  <pre><code>public class OperatorFieldsDAO
  {
      private List&lt;OperatorField&gt; OperatorFields
      {
          get
          {
              List&lt;OperatorField&gt; operatorFields = HttpContext.Current.Session["OperatorFields"] as List&lt;OperatorField&gt;;
              if (operatorFields == null)
              {
                  operatorFields = new List&lt;OperatorField&gt;();
                  operatorFields.Add(new OperatorField("string", "contains", "C"));
                  operatorFields.Add(new OperatorField("string", "begins with", "BW"));
                  operatorFields.Add(new OperatorField("string", "is equal to", "E"));
                  operatorFields.Add(new OperatorField("string", "is not equal to", "NE"));
                  operatorFields.Add(new OperatorField("string", "is less than", "L"));
                  operatorFields.Add(new OperatorField("string", "is greater than", "G"));
                  operatorFields.Add(new OperatorField("string", "is less than or equal to", "LE"));
                  operatorFields.Add(new OperatorField("string", "is greater than or equal to", "GE"));
                  operatorFields.Add(new OperatorField("string", "is from", "F"));
                  operatorFields.Add(new OperatorField("string", "is between", "B"));
                  operatorFields.Add(new OperatorField("string", "is nothing", "N"));
                  operatorFields.Add(new OperatorField("string", "is something", "S"));
  
                  operatorFields.Add(new OperatorField("number", "is the same as", "S"));
                  operatorFields.Add(new OperatorField("number", "is not the same as", "S"));
                  operatorFields.Add(new OperatorField("number", "is one of", "S"));
                  operatorFields.Add(new OperatorField("number", "is not one of", "S"));
                  operatorFields.Add(new OperatorField("number", "is nothing", "N"));
                  operatorFields.Add(new OperatorField("number", "is something", "S"));
              }
              return operatorFields;
          }
      }
      public OperatorFieldsDAO() { }
  
      [DataObjectMethod(DataObjectMethodType.Select)]
      public IEnumerable&lt;OperatorField&gt; FindAll()
      {
          return this.OperatorFields;
      }
  
      [DataObjectMethod(DataObjectMethodType.Select)]
      public IEnumerable&lt;OperatorField&gt; FindByType(String type)
      {    
          List&lt;OperatorField&gt; r = new List&lt;OperatorField&gt;();
  
          foreach (OperatorField f in this.OperatorFields)
              if (f.Type == type)
                  r.Add(f);
  
          return r;
      }
  }
  </code></pre>
  
  <p>all of this to tell you that I get an error:</p>
  
  <blockquote>
    <p>Could not find control 'hfFieldType' in ControlParameter 'Type'.</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
  <p>Do I need to programatically pass that selected parameter using the <strong>OnRowDataBound</strong> method?</p>