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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:24:52+00:00 2026-05-22T17:24:52+00:00

I have an Advanced Search form, It contains, input boxes, dropdown lists, etc. And

  • 0

I have an Advanced Search form, It contains, input boxes, dropdown lists, etc. And now I want to change a dropdown list to a multiselect list.

I can set the view, like this:

@Html.ListBoxFor(model => model.IdState, null, new { size = "7" })

But I don’t know how to change the controller from:

public ActionResult Index(FormData model)
{
    IQueryable<mytable> results = from s in db.mytable.Include("State").where(s=> (model.IdState != null ? s.IdState == model.IdState : true)) select s;
    return View(result);
}

To a multiple IdState Result???

Earlier the IdState was:

int IdState;

Now is:

IEnumerable<int> IdState;

Thanks for your time!

I still can’t make it work. In SQL will be:

SELECT * FROM MyTable WHERE IdState IN (1,2,5,7,10)

Any Idea? The http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx Don’t show similar situation

Workaround

I found on this discussion: http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/095745fe-dcf0-4142-b684-b7e4a1ab59f0/ this code snippet:

IQueryable<Foo> foos = context.Foo.Where("it.Id in {1, 2, 3, ...}");

I changed to

string sState = "";
foreach (int a in model.IdState ) sState += (a.ToString() + ",");
sState = sState .Substring(0, sState .Length - 1);
IQueryable<mytable> results = from s in db.mytable.Where("it.IdState in {" + sState + "}");

And It works great!!!

I hope can find the final solution

  • 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-22T17:24:53+00:00Added an answer on May 22, 2026 at 5:24 pm

    Instead of

    s.IdState == model.IdState 
    

    try using

    model.IdState.Contains(s.IdState)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have page with a simple table and advanced search form. I pass List<Customers>
I have a search form that executes queries returning lists of objects that are
I'm building an advanced search form for my ASP.NET MVC app. I have a
So I have an advanced search form, and when you scroll down the results,
I currently have an advanced search page that searches a number of fields in
I have written an advanced text editor component (fixed-width, syntax highlighting, etc.) in Delphi,
I have a block generated by Finder module (simple search mechanism). The block contains
I have a search form for check avaiable rooms beteen two days. After search.php,
I have written a simple mysql search form that searches between two dates. This
i have a form that have a field which hold query for search and

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.