且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将复杂字典绑定到ASP.NET中的Gridview?

更新时间:2021-12-14 03:03:11

是的,到OnItemDataBound事件。使用模板字段,插入带有href的ID的文字

Yes, you need to subsribe to the OnItemDataBound event. Use a template field, insert a literal with an ID like "href"

在OnItemDataBound事件中使用

In the OnItemDataBound event use

Literal _href = e.Row.FindControl("href") as Literal;  
if(_href != null)
{
  _href = ((LinkInfo)e.Row.DataItem).href;
}

编辑:我写了一篇文章进一步阐述此主题: http://www.tomot.de/en-us/article/7/asp.net/gridview-overview-of-different-ways-to-bind-data-to-columns

Edit: I've written an article that elaborates this topic further: http://www.tomot.de/en-us/article/7/asp.net/gridview-overview-of-different-ways-to-bind-data-to-columns