在webgrid帮助器中创建单元格链接 [英] creating cell links in webgrid helper
问题描述
var gridTotal = new WebGrid(qOrdersList);
上述查询的结果是一个包含一些列的表,包括:AuditNum(一个int)和Status。我想用以下代码在webgrid中显示它:
The result of the above query is a table with some columns including: AuditNum (an int) and Status. I want to display it in a webgrid with this code:
@gridTotal.GetHtml(
columns : gridTotal.Columns
(
gridTotal.Column(
columnName : "AuditNum",
format: @<a href="@App.PathOrderEdit?AuditNum=x">x</a>
),
gridTotal.Column(
columnName : "Status")
)
);
问题是我想要创建的链接。 ''''将是当前行的AuditNum列的值,我希望它是链接的文本,也可以在href属性中用作参数。我不知道如何访问它。例如:
AuditNum ----状态
100 ------------ A
101 ------------ B
。
。
。
我想让这两个数字成为这些页面的链接:
@ App.PathOrderEdit?AuditNum = 100
@App .PathOrderEdit?AuditNum = 101
The problem is the link that I want to create. ''x'' is going to be the value of AuditNum column for the current row that I want it to be the text of the link and also be used in the href attribute as a parameter. I dont know how to access that. Example:
AuditNum ---- Status
100 ------------ A
101 ------------ B
.
.
.
I want to make those 2 numbers a link to these pages:
@App.PathOrderEdit?AuditNum=100
@App.PathOrderEdit?AuditNum=101
推荐答案
您应该按如下方式修改代码:
You should modify your code as follows:
@gridTotal.GetHtml(
columns : gridTotal.Columns
(
gridTotal.Column(
columnName : "AuditNum",
format: @<a href="@App.PathOrderEdit?AuditNum=@item.AuditNum">@item.AuditNum</a>
),
gridTotal.Column(
columnName : "Status")
)
);
这篇关于在webgrid帮助器中创建单元格链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!