0

I applied a query extender to my text box for three fields. Its Working but it is case sensitive. e.g. if a username field is having a name "AWAIS" and i search for "awais" , it does not search and vice virsa. How can i remove sensitivity ?

My Code is

    <td>
                <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="BookStore.Bussines.Entities.BookStoreEntities"
                    OnSelecting="LinqDataSource1_Selecting">
                </asp:LinqDataSource>
                <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="LinqDataSource1">
                    <asp:SearchExpression DataFields="DISTRIBUTOR_NAME,DISTRIBUTOR_CODE,DISTRIBUTOR_URL" SearchType="Contains">
                        <asp:ControlParameter ControlID="txtSearchDistributor" />
                    </asp:SearchExpression>
                </asp:QueryExtender>
            </td>
Awais Alvi
  • 29
  • 1
  • 8

3 Answers3

0

If you look at the documentation on MSDN for this control you would see how case sensitivity is handled:

Case sensitivity in the search expression depends on the LINQ provider that you specify in the QueryExtender control.

Jamie Keeling
  • 9,806
  • 17
  • 65
  • 102
0

Try this:

Set SearchExpression.ComparisonType to StringComparison.OrdinalIgnoreCase

<asp:SearchExpression DataFields="DISTRIBUTOR_NAME,DISTRIBUTOR_CODE,DISTRIBUTOR_URL" SearchType="Contains" ComparisonType=StringComparison.OrdinalIgnoreCase>
                        <asp:ControlParameter ControlID="txtSearchDistributor" />
                    </asp:SearchExpression>

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.expressions.searchexpression.comparisontype%28v=vs.110%29.aspx

https://msdn.microsoft.com/en-us/library/system.stringcomparison%28v=vs.110%29.aspx

malkam
  • 2,337
  • 1
  • 14
  • 17
0

According to the documentation:

Case sensitivity in the search expression depends on the LINQ provider that you specify in the QueryExtender control.

If the LINQ provider that you use in the QueryExtender control supports case sensitivity, you can use the ComparisonType property to enable or ignore case sensitivity.

Another Possibility - Database Collation

Perhaps your database is set up to be case sensitive. Some links if you're using SQL Server.

SQL Server Collation Description

Description of Collations

Rick S
  • 6,476
  • 5
  • 29
  • 43