MVC Search by Id which is int type:

Feb 14 2018 7:35 PM

Hey can anyone help me for: 

my code is : //SearchByID

public ActionResult SearchByID(string txtID)

{

var IDList = from n in db.tblDonors select n;

if (!String.IsNullOrEmpty(txtID))

{

IDList = IDList.Where(c =>Convert.ToString( c.D_ID).Contains(txtID));

}

return View(IDList);

}


I'm getting the following error:

LINQ to Entities does not recognize the method 'System.String ToString(Int32)' method, and this method cannot be translated into a store expression.Edit (0)

Answers (3)