MVC3 WebGrid Custom Text in Column

前端 未结 2 1445
南旧
南旧 2021-01-02 11:38

I\'m developing a web application using MVC3 in VB.NET.

I having difficulty setting a column on the webgrid with the following action links

Edit | De

相关标签:
2条回答
  • 2021-01-02 12:19

    Can also use the below which is more like the normal way so I like it better:

    grid.Column(format: @<text>
                    @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.Id })    
         </text>)
    
    0 讨论(0)
  • 2021-01-02 12:31
    grid.Column(
    columnName:"PrimaryKey", 
    header:"Actions",      
    format: (item) => 
    {
       var links = Html.ActionLink("Edit", "Edit", new {id = item.PrimaryKey}) + " | " +
                   Html.ActionLink("Details","Details", new { id = item.PrimaryKey}) +" | "+
                   Html.ActionLink("Delete","Delete", new { id = item.PrimaryKey});
    
       return Html.Raw(links);
    
    }),
    

    renders the following HTML (formatted for legibility)

    <td>
      <a href="/Home/Edit/5">Edit</a> | 
      <a href="/Home/Details/5">Details</a> | 
      <a href="/Home/Delete/5">Delete</a>
    </td>
    
    0 讨论(0)
提交回复
热议问题