ASP.NET MVC3 WebGrid format: parameter

后端 未结 3 916
北海茫月
北海茫月 2021-01-04 09:23

I am trying to use the new WebGrid in ASP.NET MVC3 and one of the columns I want to display set of link icons that performs various actions (Edit, View, Delete)... For this

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 09:47

    I had to create a WebGrid in C# code and had to display a specific column using hyperlink. None of the techniques mentioned above worked for me. So, I used MvcHtmlString.create and passed in the return value of String.format to it.

    
      format: (item) => MvcHtmlString.Create(string.Format((A HREF=\"/Inventory/EditInventory/{0}\"){1}(/A)", item.ID, item.Property))) 
    

    Replace the ( or ) inside the string with < or > respectively.

提交回复
热议问题