I have a basic EntityDataSource related to a GridView. I have a TextBox over a GridView for search.
My goal: a) Custom "jon" types b) GridView filters, for example. Jonathan, Enjona, Jonas.
I saw several examples of how to add a parameterized LIKE clause to the Where property of my data source, however they all need the user to use a wildcard in the search bar (for example,% Jon instead of Jon). This is not acceptable for casual users, so I want to put the template in the Where clause instead.
The syntax in SQL is obvious: SELECT Name FROM Names WHERE Name LIKE N '% @ p1%'
In other words, if @ p1 = 'Jon', my suggestion is WHERE LIKE N '% Jon%'.
Frustrated, the Where clause in EntityDataSource does not seem to work this way. In other words, the following does not work:
<asp:EntityDataSource ID="edsNames" runat="server"
ConnectionString="name=SalesEntities"
DefaultContainerName="SalesEntities" EntitySetName="Names"
OrderBy="it.Name" Where="it.Name LIKE '%@p1%'">
<WhereParameters>
<asp:ControlParameter ControlID="txtFilter" Name="p1"
PropertyName="Text" Type="String" DefaultValue="" />
</WhereParameters>
</asp:EntityDataSource>
I would gladly expect the default "to provide me with my" get everything "suggestion, that is, LIKE" %% ", but nothing is returned in my GridView.
Frustrated if I hard-coded the search result, for example. Where = "it.Name LIKE"% Jon% '", it works great.
Does anyone know how to do this?