1

I am trying to perform a single search on a single column of data in an asp:GridView, however I want multiple filter (search) boxes above each column so one could search within its own perspective column. What would clearly fix this theoretically is to have multiple FilterExpressions. I am using VB and am very new and easily misunderstood with VB, please bare with:

PS. I have gotten it to work no problem when only having ONE filter (search) box, this currently doesn't do anything

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="xxx" 
    ProviderName="xxxx" 
    SelectCommand="SELECT [ddiID], [volusionID], [Customer], [email], [Total], [SumOfTotal] FROM [BBnewsalesQry] ORDER BY [Customer]"
    FilterExpression="customer like '%{0}%' OR ddiID like '%{0}%'">
      <FilterParameters>
         <asp:ControlParameter Name="ddiID" ControlID="ddiIDSearch" PropertyName="Text" />
         <asp:ControlParameter Name="customer" ControlID="txtSearch" PropertyName="Text" />
      </FilterParameters>
</asp:SqlDataSource>
<div>
   <b>DDI Search:</b> <asp:TextBox ID="ddiIDSearch" runat="server" />
   <b>Customer Search:</b> <asp:TextBox ID="txtSearch" runat="server" />
   <asp:ImageButton ID="btnSearch" ImageUrl="http:xxx" runat="server" />
   <asp:ImageButton ID="btnClear" ImageUrl="http:xxx" runat="server" />
</div>

Then inside the GridView:

<asp:TemplateField HeaderText="ddiID" SortExpression="ddiID">
        <ItemStyle HorizontalAlign="Left" />
           <ItemTemplate>
              <asp:Label ID="lblddiid" Text='<%#HighlightText(Eval("ddiid")) %>' 
                        CssClass="TextField" runat="server" />
           </ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="volusionID" HeaderText="volusionID" ReadOnly="True" SortExpression="volusionID" />
<asp:TemplateField HeaderText="customer" SortExpression="customer">
         <ItemStyle HorizontalAlign="Left" />
           <ItemTemplate>
              <asp:Label ID="lblcustomer" Text='<%#HighlightText(Eval("customer")) %>' 
                        CssClass="TextField" runat="server" />
           </ItemTemplate>
</asp:TemplateField>

2 Answers 2

7

you are referencing the same parameter twice - try the following:

FilterExpression="customer like '%{0}%' OR ddiID like '%{1}%'"
Sign up to request clarification or add additional context in comments.

Comments

0

I have resolved the problem of create two or more "Like clause" in the "Where" statement using:

Where CHARINDEX(@Par1, Col1)<>0) and ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.