I have the following code shown below. When I uncomment the area that has
    alert('Key ' + item.KeyID)
I do get the key value just fine. But when I do:
     select: function (event, ui)                        
and try to fetch the KeyID it shows as undefined.
$(document).ready(function () {
   $('#Company').autocomplete(
           {
               source: function (request, response) {
                   $.ajax({
                       url: '@Url.Action("AutoCompleteCompany", "Main")',
                       type: "POST",
                       dataType: "json",
                       data: { term: request.term },
                       success: function (data) {
                           response($.map(data, function (item) {
                               //alert('Key ' + item.KeyID);
                               //alert('Value ' + item.KeyValue);
                               return {label: item.KeyValue, val: item.KeyID };
                           }))
                       }
                   })
               },
               select: function (event, ui) {                       
                  alert(ui.item.KeyID);   // shows undefined                    
               }
           });
})
 
     
    