Hi sallmomar,
You have to use Substring function.
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
View
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
$(function () {
$('[id*=Title]').on('blur', function () {
$.getJSON('Home/GetEmployees', { title: $(this).val() }, function (response) {
if (response.length > 0) {
$("[id*=tblEmployees] tbody").empty();
var row;
$.each(response, function (recherche, item) {
row += "<tr><td>" + item.Id + "</td><td>" + item.Name + "</td></tr>"
})
$("[id*=tblEmployees] tbody").append(row);
}
}).fail(function (response) {
});
});
});
</script>
<table>
<tr>
<td><%:Html.TextBox("Title") %></td>
</tr>
</table>
<table id="tblEmployees">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
return View();
}
public ActionResult GetEmployees(string title)
{
NorthwindEntities db = new NorthwindEntities();
if (!string.IsNullOrWhiteSpace(title))
{
List<Employee> employees = db.Employees.Where(t => t.Title.Substring(0, 5).ToLower() == title.ToLower())
.Select(x => new Employee
{
Id = x.EmployeeID,
Name = x.FirstName + " " + x.LastName
}).ToList();
return Json(employees, JsonRequestBehavior.AllowGet);
}
return null;
}
}
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
}
Screenshot
![](https://i.imgur.com/G8khczj.gif)