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);
}
To search with number, change the method in question to the following :
Another method is :
And the view looks like that :