MVC 3 Webgrid 专栏
我目前正在开发 MVC 3 网络网格,在我希望有一个按钮的列之一中,当我将以下代码放入视图中时,我已经实现了这一点。
@grid.GetHtml(columns:
grid.Columns(
grid.Column("ID", "id", canSort: true),
grid.Column("Surname", "surname", canSort: true),
grid.Column("Forenames", "forename", canSort: true),
grid.Column(format: @<input type="button" value="View"/>)),
headerStyle: "header",
alternatingRowStyle: "alt",
htmlAttributes: new { id = "DataTable" }
)
但是,我希望创建网格服务器端以进行分页,但是当我将下面的代码放入操作中时,我收到按钮列的错误。
var htmlString = grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
htmlAttributes: new { id = "DataTable" },
columns: grid.Columns(
grid.Column("ID", "id", canSort: true),
grid.Column("Surname", "surname", canSort: true),
grid.Column("Forenames", "forename", canSort: true),
grid.Column(format: @<input type='button' value='View'/>)
));
第一个错误是“逐字说明符后需要关键字、标识符或字符串:@”。
我在按钮列上使用的格式是否不正确?
I'm working on a MVC 3 webgrid at the moment, in one of the columns I wish to have a button, I've achieved this when putting the following code in the view.
@grid.GetHtml(columns:
grid.Columns(
grid.Column("ID", "id", canSort: true),
grid.Column("Surname", "surname", canSort: true),
grid.Column("Forenames", "forename", canSort: true),
grid.Column(format: @<input type="button" value="View"/>)),
headerStyle: "header",
alternatingRowStyle: "alt",
htmlAttributes: new { id = "DataTable" }
)
However I wish to create the grid server side for the purpose of paging, but when I put the code below in the action I get a error for for the button column.
var htmlString = grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
htmlAttributes: new { id = "DataTable" },
columns: grid.Columns(
grid.Column("ID", "id", canSort: true),
grid.Column("Surname", "surname", canSort: true),
grid.Column("Forenames", "forename", canSort: true),
grid.Column(format: @<input type='button' value='View'/>)
));
The first error is "Keyword, identifier, or string expected after verbatim specifier: @".
Am I using the incorrect format on the button column?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试像这样的剃须刀的
标签;you can try
<text>
tag for razor like this;您似乎正在尝试在代码隐藏中使用 Razor 语法。尝试这样的事情,使用 lambda 表达式......
It looks like you're attempting to use Razor syntax in your code-behind. Try something like this, using a lambda expression...