title: Error using QueryExtender with an EntityDataSource - 'FirstName' is not a member of type 'System.Data.Common.DbDatRecord'
body: <p>The following GridView with an EntityDataSource that grabs 3 fields from the Surveyors table (which contains more fields) works, but of course it shows me every Surveyor.</p>
  
  <pre><code>&lt;asp:GridView ID="gvwSurveyors" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" DataSourceID="edsSurveyors"&gt;
    &lt;Columns&gt;
      &lt;asp:BoundField DataField="FirstName" HeaderText="FirstName" ReadOnly="True" SortExpression="FirstName" /&gt;
      &lt;asp:BoundField DataField="LastName" HeaderText="LastName" ReadOnly="True" SortExpression="LastName" /&gt;
      &lt;asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" /&gt;
    &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  &lt;asp:EntityDataSource ID="edsSurveyors" runat="server"
    ConnectionString="name=PLSOEntities"
    DefaultContainerName="PLSOEntities"
    EnableFlattening="False"
    EntitySetName="Surveyors"
    Select="it.[FirstName], it.[LastName], it.[ID]"
    AutoGenerateOrderByClause="true"&gt;
    &lt;OrderByParameters&gt;
      &lt;asp:Parameter DefaultValue="LastName" /&gt;
    &lt;/OrderByParameters&gt;
  &lt;/asp:EntityDataSource&gt;
  </code></pre>
  
  <p>So in order to get the initial page load to not show everything I added the OnSelecting event to the EntityDataSource and have it cancel the query if it is Not a postback.</p>
  
  <pre><code>protected void edsSurveyors_Selecting(object sender, EntityDataSourceSelectingEventArgs e) {
    if (!Page.IsPostBack)
      e.Cancel = true;
  }
  </code></pre>
  
  <p>I have two text boxes named txtFirstName and txtLastName that I want the user to be able to search using a SQL query LIKE style.  Some reading on the web pointed me toward the QueryExtender.  I changed the code to the following:</p>
  
  <pre><code>&lt;asp:GridView ID="gvwSurveyors" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" DataSourceID="edsSurveyors"&gt;
    &lt;Columns&gt;
      &lt;asp:BoundField DataField="FirstName" HeaderText="FirstName" ReadOnly="True" SortExpression="FirstName" /&gt;
        &lt;asp:BoundField DataField="LastName" HeaderText="LastName" ReadOnly="True" SortExpression="LastName" /&gt;
        &lt;asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" /&gt;
      &lt;/Columns&gt;
    &lt;/asp:GridView&gt;
    &lt;asp:EntityDataSource ID="edsSurveyors" runat="server"
      ConnectionString="name=PLSOEntities"
      DefaultContainerName="PLSOEntities"
      EnableFlattening="False"
      EntitySetName="Surveyors"
      Select="it.[FirstName], it.[LastName], it.[ID]"
      AutoGenerateOrderByClause="true" onselecting="edsSurveyors_Selecting"&gt;
      &lt;OrderByParameters&gt;
        &lt;asp:Parameter DefaultValue="LastName" /&gt;
      &lt;/OrderByParameters&gt;
    &lt;/asp:EntityDataSource&gt;
    &lt;asp:QueryExtender ID="qexSurveyor" runat="server" TargetControlID="edsSurveyors"&gt;
      &lt;asp:SearchExpression SearchType="Contains" DataFields="FirstName"&gt;
        &lt;asp:ControlParameter ControlID="txtFirstName" /&gt;
      &lt;/asp:SearchExpression&gt;
    &lt;/asp:QueryExtender&gt;
  </code></pre>
  
  <p>So now when I click the button I get the error: 'FirstName' is not a member of type 'System.Data.Common.DbDataRecord'</p>
  
  <p>What can I do to allow a Contains?  Once it works, I will then added a LastName parameter that does the same.</p>