WebGrid的标头格式

我刚刚阅读: 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 

我想让每个Cell都可以点击,并且根据它所在的列,我希望它的相应超链接与另一个单元格的超链接不同。

可以使用WebGrid完成吗? 我在PHP中完成了这个,但不知道在哪里查看,或者如何使用WebGrid。

在搜索Google,Bing和Yahoo!(?)之后,我只看到那些优质WebGrid组件的结果,而不是真实WebGrid的单个结果,也没有任何有用的结果。

在您参考的Mike的DotNetting文章中,他展示了如何在以下代码行中显示shortdate:

 format: @@item.DatePublished.ToShortDateString() 

由于格式替换了整个单元格,因此您只需要放置生成所需HTML的代码,包括超链接。 由于产生任何复杂的东西可能会使这行代码太难以阅读,因此最好编写自己的类/函数来生成所需的代码。 我有这种情况,我的格式行看起来像:

 format : @@Html.Raw(NDisplay.displayComment( username, item.AssignedTo, item.NALComment, item.refID, item.Process)), 

然后在那个function:

 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 = "Edit " + NALComment; return e; } 

在每个单元格中,都有一个编辑超链接,后跟文本注释。