我刚刚阅读了:http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid,并看到了对[Optional, Default Value(null)] string header的引用
如果不需要数据库字段名称,则为标题文本
但是我不确定如何格式化单元格值。例如,如果我有一个如下所示的WebGrid:
Column Name Column Name Column Name Column Name
Cell value Cell value Cell value Cell value
Cell value Cell value Cell value Cell value
Cell value Cell value Cell value Cell value
Cell value Cell value Cell value Cell value
Cell value Cell value Cell value Cell value 我希望每个单元格都可以单击,并且根据它所在的列,我希望其相应的超链接与另一个单元格的超链接不同。
使用WebGrid可以做到这一点吗?我已经用PHP实现了这一点,但不知道从哪里看,也不知道如何用WebGrid来实现。
在搜索谷歌、必应和雅虎(?)时,我只看到那些高级WebGrid组件的结果,没有一个真正的WebGrid的结果,也没有任何有帮助的结果。
发布于 2011-03-24 19:54:09
在您引用的Mike的DotNetting文章中,他展示了如何在以下代码行中显示短日期:
format: @<text>@item.DatePublished.ToShortDateString()</text>由于格式替换了整个单元格,因此您只需放置生成所需HTML的代码,包括超链接。由于生成任何复杂的代码可能会使该行代码难以阅读,因此最好编写自己的类/函数来生成所需的代码。我有这样的情况,我的格式行看起来像这样:
format : @<text>@Html.Raw(NDisplay.displayComment( username, item.AssignedTo, item.NALComment, item.refID, item.Process))</text>,然后在该函数中:
public static string displayComment( string username, string AssignedTo, string NALComment, int refID, string Process)
{
// various junk code removed, testing user and rights
// here we know we have the right user, he or she needs the edit URL
// two parameters are passed, first the refID, second the Process (or document)
string e = "<a href =\"../Process/" + refID.ToString() + "/" + Process +"/\">Edit</a> " + NALComment;
return e;
}在每个单元格中,都有一个编辑超链接,后跟一个文本注释。
https://stackoverflow.com/questions/5413069
复制相似问题