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 9143245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:58:31+00:00 2026-06-17T09:58:31+00:00

Does anyone know how, or have any links on how to filter the data

  • 0

Does anyone know how, or have any links on how to filter the data returned in a textbox that is based on the value of the selected item in a dropdownlist.

i.e If a user selects hotel from a list, then when they start typing in the textbox only the address of the companies whos category matches hotel will appear using autocomplete.


I have added my server side code below, but I’m getting the following error.

public JsonResult FilterDirectorySearch(string searchText, string context)
        {
        var wq = DirectoryList(searchText,context).Select(a =>
           new { Location = a.strLocationSearch });
        return Json(wq.Distinct(), JsonRequestBehavior.AllowGet);
        }

    private List<DisplayDirectoryDataForSearchBox> DirectoryList(string searchString, string context)
        {
        var wq = _IGTDD.DisplayDirectoryData()
                  .Where(a => a.strLocationSearch.Contains(searchString, StringComparison.OrdinalIgnoreCase) && a.strCategory = context).ToList();
        return wq.ToList();
        }

Errors
Error 1 Instance argument: cannot convert from ‘string’ to ‘System.Linq.IQueryable’

Error 2 ‘string’ does not contain a definition for ‘Contains’ and the best extension method overload ‘System.Linq.Queryable.Contains(System.Linq.IQueryable, TSource, System.Collections.Generic.IEqualityComparer)’ has some invalid arguments

Error 3 Argument 3: cannot convert from ‘System.StringComparison’ to ‘System.Collections.Generic.IEqualityComparer’

Forgot to add this error for the code below

return (from x in wq where x.strLocationSearch.StartsWith(searchString, StringComparison.OrdinalIgnoreCase) && x.strCategory = context select x.strLocationSearch).AsEnumerable();

Error message: Error 1 Operator ‘&&’ cannot be applied to operands of type ‘bool’ and ‘string’

  • 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-06-17T09:58:32+00:00Added an answer on June 17, 2026 at 9:58 am

    Any Autocomplete javascript tooling generally allows you to configure the source as a function, being either a javascript function and local data, or a function to an AJAX server source.

    Within either the local javascript function or the remove AJAX responder, you can simply add the extra context data, by pulling the value from the required dropdown box.

    Handling would then be either in the local javascript code or in the remote AJAX responder to deal with the extra information.

    Without any context of what autocomplete coding you are using, it’s difficult to illustrate my answer with code.

    However, if you’re using jQuery, Autocomplete UI and an AJAX function for the source:

    $("#autocompleteTextBox").autocomplete({
        source: function(request, response) {
            var autocompleteContext = $("#dropdownBox").val();
            $.ajax({
                url: "http://source.com/searchJSON",
                dataType: "jsonp",
                data: {
                    query: request.term,
                    context: autocompleteContext
                },
                success: function(data) {
                    ...
    

    Note the two lines:

    1. Where autocompleteContext variable is set, presumably from the dropbox you speak of
    2. Where autocompleteContext is fed through to the searchJSON action in the data parameter

    On the server-side (handler of searcjJSON) [C#/MVC psuedocode]:

    public List<string> searchJSON(string query, string context)
    {
       return (from x in db.SearchTable where x.Name.Contains(query) && x.context == context select x.Name).ToList()
    }
    

    If you’re merely using a local array source in javascript, change to a function source, similar to the AJAX source…

    var fullArray = ["Apple", "Bat", "Cat", "Dog"];
    $("#autocompleteTextBox").autocomplete({
        source: function(request, response) {
            var autocompleteContext = $("#dropdownBox").val();
            response = //Code to filter fullArray with request.term and autocompleteContext here
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know there have any other way that (by not using json_encode and
Does anyone know do there have any way that I can encrypt the array
Does anyone know if there have been any changes in Azure publish to allow
Does anyone have any ideas or know of any plugins to allow pages to
Does anyone know of any publicly available Question answering applications which have built using
Does anyone know of any way to overcome NotSupportedException? I have a method against
Does any one know how I would have to change the following to work
Does anyone know how to or have some code on counting the number of
Does anyone know why the STL containers don't have virtual destructors? As far as
Does anyone know of a good way to have a user enter an amount

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.