MVC3的WebGrid自定义文本在列

MVC3的WebGrid自定义文本在列

本文介绍了MVC3的WebGrid自定义文本在列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在开发使用VB.NET MVC3 Web应用程序。

我有困难就设置的WebGrid一列用下面的操作链接

编辑|详情|删除

  @ * @ Html.ActionLink(编辑,编辑,随着新.ID {= currentItem.PrimaryKey})|
@ Html.ActionLink(详细信息,详细信息,随着新.ID {= currentItem.PrimaryKey})|
@ Html.ActionLink(删除,删除,随着新.ID {= currentItem.PrimaryKey})* @

我曾尝试使用下面的语法,但我得到的地方项目未声明的错误。

grid.Column(标题:=,格式为:=(项目)=> item.GetSelectLink(自定义文本))

我如何引用当前行或项目中的WebGrid,使这项工作?

任何帮助非常AP preciated。

问候

詹姆斯


解决方案

  grid.Column(
COLUMNNAME:PrimaryKey的
标题:操作,
格式:(项目)=>
{
   VAR链接= Html.ActionLink(编辑,编辑,新{ID = item.PrimaryKey})+|+
               Html.ActionLink(详细信息,详细信息,新{ID = item.PrimaryKey})+|+
               Html.ActionLink(删除,删除,新{ID = item.PrimaryKey});   返回Html.Raw(链接);}),

呈现以下HTML(格式化的可读性)

 < TD>
  < A HREF =/首页/编辑/ 5>编辑< / A> |
  < A HREF =/主页/细节/ 5​​>详情< / A> |
  < A HREF =/首页/删除/ 5>删除< / A>
< / TD>

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 | Details | Delete

@*@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.PrimaryKey}) |
@Html.ActionLink("Details", "Details", New With {.id = currentItem.PrimaryKey}) |
@Html.ActionLink("Delete", "Delete", New With {.id = currentItem.PrimaryKey})*@

I have tried to use syntax below but I get an error where item is not declared.

grid.Column(header:= "",format:= (item) => item.GetSelectLink("Custom Text"))

How do I reference the current row or item in a webgrid to make this work?

Any help greatly appreciated.

Regards

James

解决方案
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>

这篇关于MVC3的WebGrid自定义文本在列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:22