Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3356756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:33:04+00:00 2026-05-18T02:33:04+00:00

I have an SqlDataSource in a page, which will display different results depending on

  • 0

I have an SqlDataSource in a page, which will display different results depending on 1 or 2 query strings, and/or a filter textbox.

Here is my SqlDataSource and filters:

  <asp:SqlDataSource ID="sdsAudits" runat="server" 
        ConnectionString="<%$ ConnectionStrings:constring %>" 
        SelectCommand="SELECT * FROM [Audit]" FilterExpression="source = {0} AND customer = {1} AND (itemID like '%{2}%' OR parentID like '%{2}%')">
        <FilterParameters>
        <asp:QueryStringParameter Name="source" QueryStringField="source" />
        <asp:QueryStringParameter Name="customer" QueryStringField="customer" />
        <asp:ControlParameter Name="txtFilter" ControlID="txtFilter" PropertyName="Text" />
        </FilterParameters>

But for some reason, the filtering for any of the 3 possible filters don’t work. I tried taking out the 2 query string filters, and leaving just the textbox filter, and it worked fine then – so I’m guessing my filter expression is wrong?

Any ideas guys? Remember all 3 filters could be ‘active’ at once, if they have the 2 query strings and have typed into the textbox, or they could be none at all, or of course anything in between.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:33:04+00:00Added an answer on May 18, 2026 at 2:33 am

    Filter is intended to work in DataSet mode – data is retrieved into memory, and then filtered. Not very efficient – much better to use parameters in the select command itself, like so:

    <asp:SqlDataSource ID="sdsAudits" runat="server" 
        ConnectionString="<%$ ConnectionStrings:constring %>" 
        SelectCommand="SELECT * FROM [Audit] where source = @source AND customer = @customer AND (itemID like '%' + @txtFilter + '%' OR parentID like '%'+@txtFilter+'%')">
        <SelectParameters>
          <asp:QueryStringParameter Name="source" QueryStringField="source" />
          <asp:QueryStringParameter Name="customer" QueryStringField="customer" />
          <asp:ControlParameter Name="txtFilter" ControlID="txtFilter" PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource>
    

    or just add

      DataSourceMode="DataSet"
    

    to your SqlDataSource tag

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have gridview in my asp.net page which is bound to sqldatasource. when i
Here I have created a website in c#.net and I want the page which
I have a gridview and sqldatasource. I want to display in a label, the
I have a GridView in ASP.net which is filled from an SqlDataSource. one of
I have the following which works fine: <%@ Page Language=C# AutoEventWireup=true CodeFile=Default2.aspx.cs Inherits=test_library_newsletter_Default2 %>
I have a sqldatasource where i have added a simple filter expression just for
On my page I have a DropDownList which I populate with database values from
I have an asp.net dropDownList which is automatically bound to a sqlDataSource to values
So I have an ASP.NET page with two controls: a GridView which displays rows
I have a GridView and a SqlDataSource, which I have set to automatically generate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.