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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:08:38+00:00 2026-06-11T02:08:38+00:00

As you can see, I have a method to retrieve fields from my table.

  • 0

As you can see, I have a method to retrieve fields from my table. In my view, I do the search in two textbox.

ClientID is a string, so no problem it works. But OrderId is an Int, so I use ToString() but it still don’t work.

Am I wrong in the way I wrote my second IF condition for OrderId ? Thanks for your help

public ActionResult Search(string searchString, string searchOrder)
{  
    var user = from m in db.Order   
               select m;

    if (!String.IsNullOrEmpty(searchString))
    {
        user = user.Where(s => s.Order.ClientID.Contains(searchString));
    }         

    if (!String.IsNullOrEmpty(searchOrder))
    {
        user = user.Where(c => c.Order.OrderId.ToString().Contains(searchOrder));
    }

    return this.View("Order", "PrintView", user);
}
  • 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-11T02:08:39+00:00Added an answer on June 11, 2026 at 2:08 am

    To search with number, change the method in question to the following :

     public ActionResult PrintOrders(string searchString, int searchOrder = 0)
        {
            var user = from m in db.OrderDetails   
                       select m;
    
            if (!String.IsNullOrEmpty(searchString))
            {
                user = user.Where(s => s.Order.ClientID.Contains(searchString));               
            }
    
            if (searchOrder > 0)
            {
                user = user.Where(c => c.Order.OrderId == searchOrder);               
            }
    
            return this.ViewPdf("Order", "PrintView", user);
        }
    

    Another method is :

        public ActionResult PrintOrders(string searchString, string searchOrder)
        { 
            var user = from m in db.OrderDetails   
                       select m;
    
            if (!String.IsNullOrEmpty(searchString))
            {
                user = user.Where(s => s.Order.ClientID.Contains(searchString));               
            }
    
            int tmp = Int32.Parse(searchOrder);
    
            if (tmp != 0)
            {
                user = user.Where(c => c.Order.OrderId == tmp);
            }
    
            return this.ViewPdf("Order", "PrintView", user);
        }
    

    And the view looks like that :

    @using (Html.BeginForm("PrintOrders", "Historic", FormMethod.Get, new { target = "_blank" }))
    {
    
       Search by Client ID : @Html.TextBox("searchString")
    
       Search by Order ID : @Html.TextBox("searchOrder")
    
      <input type="submit" value="Search" />
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two methods that (as you can see) are similar in
I have a web page where users can see data from MongoDB on a
I have this: As you can see I currently have a conditional to include
Trying not to lose it here. As you can see below I have assigned
I have firebug installed and I can see on one of my 'Net' requests
I have the following and you can see I am trying to pass this
I have a Mercurial repository that I can see just fine if I navigate
I have the following HTML and you can see the extra space between the
I have this JSON and you can see under products i have barcodes for
As you can see, that I have put my the national flags in a

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.