2012-05-10 42 views
0

我努力:數據上看不到Asp.Net MVC3 UI

通行證ID來獲得控制結果與顯示的結果與UI MVC3 Asp.Net/JQuery的

我做了什麼:

我有一個位指示([HttpPost] Index(Int? id)),其reurns listDetails以查看

我有通過jquery的傳遞ID到控制器指數,並得到作爲listDetails模型查看的文本框

現在我正在嘗試顯示@Model.xyz.Name

我試着用控制器中的斷點和模型來調試代碼,並且它得到有效的數據。

我在視圖中嘗試了斷點並獲取數據。

但是當我運行應用程序時數據在UI上根本不可見。 有人能告訴我我要去哪裏嗎?

控制器代碼

[HttpGet] 
public ActionResult Index() 
{ 
    return View(); 
} 



[HttpPost] 
     public ActionResult Index(int? Id) 
     { 
      if (Id.HasValue) 
      { 
get list of values 
    return View(listOfValues); 
} 

查看代碼

@if (@Model != null) 
      { 
       @Model.Person.DisplayName 
      } 

jQuery代碼具有自動完成(觸發選擇)

$(document).ready(function() { 

    $(function() { 

     $("#tbxSearch").autocomplete({ 
      source: function (request, response) { 
       $.ajax({ 
        url: "/Details/GetSearchData", type: "POST", dataType: "json", 
        data: { searchText: request.term, maxResults: 10 }, 
        success: function (data) { 
         response($.map(data, function (item) { 
          return { label: item.label, value: item.label, id: item.value } 
         })) 
        } 
       }) 
      }, 
      select: function (event, ui) { 
       //alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.id) 
       //  : "Nothing selected, input was " + this.value); 
       $.ajax({ url: 'PersonDetails', 
        type: 'POST', 
        data: { id: ui.item.id 
        }, 
        async: false, 
        success: function (result) { 
         // alert("Success"); 
         //$('#DivDetails').show(); 
        } 
       }); 
      } 
     }); 

    }); 

}); 

回答

0

什麼在視圖頂部using語句?它是IEnumerable嗎?看起來你正在返回一個Person列表。

試着說foreach(模型中的var item)...看看你是否看到任何東西。

+0

我試過在View中調試代碼。它在@ Model.xyz.Name中顯示值 – Kurkula