2011-01-05 59 views
1

我顯示一個帶有用戶名列表的小表,並且我希望每個用戶名旁邊都有一個ActionLink來編輯另一個頁面上的用戶。Html ActionLink不顯示

這是我的看法頁:在EmployeeController

<%@ Page Title="" Language="C#" 
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<WebUI.Models.IndexModel>>" %> 

<table> 
    <tr> 
     <th></th> 
     <th>Username</th> 
    </tr> 
    <% foreach (var item in Model) { %> 
    <tr> 
     <td><% Html.ActionLink("Edit", "Edit", "Employee", new { id = item.UserID }, null); %></td> 
     <td><%: item.Username %></td> 
    </tr> 
    <% } %> 
</table> 

我的控制器方法:

public ActionResult Index() 
{ 
    List<IndexModel> model = new List<IndexModel>(); 

    //load model with data 

    return View(model); 
} 

public ActionResult Edit(Guid id) 
{ 
    return View(); 
} 

我的模型:

public class IndexModel 
{ 
    public Guid UserID { get; set; } 
    public string Username { get; set; } 
} 

的用戶名正確顯示,僅僅是鏈接不出現。我不知道爲什麼它不會拋出一個錯誤。

我在這裏錯過了什麼?

回答

2

嘗試刪除;和添加:在─

<%:Html.ActionLink("Edit", "Edit", "Employee", new { id = item.UserID }, null) %> 
+1

謝謝:)它總是小事情,不是嗎... – Steven 2011-01-05 20:45:35

4

你缺少一個:在你的代碼。 試試這個:

<td><%: Html.ActionLink("Edit", "Edit", "Employee", new { id = item.UserID }, null) %></td> 

編輯:刪除了;最後沒有注意到它。