2010-06-06 4 views
1

나는 초기의 바인딩을 사용하여 dictionary<string, string>을 gridview에 사용하여 Urls Text와 해당 HRef를 키 - 값으로 표시하고 매력처럼 작동합니다. 나는이 하나를 사용하여 사전을 대체 할 때문에 는하지만 :asp.net에서 Gridview에 복잡한 사전을 바인딩하는 방법?

dictionary<string, LinkInfo> 

바인딩이 잘못! onItemDataBound 또는 뭔가 같은 일부 이벤트를 처리해야합니까? 과 LinkInfo 구조는 다음과 같습니다

public struct LinkInfo{ 
    public string href; 
    public bool Enabled; 
} 

답변

1

예, 당신은 OnItemDataBound 이벤트에 subsribe해야합니다. 사용 템플릿 필드를 사용하여 OnItemDataBound 이벤트에서 "HREF"

같은 ID를 가진 문자를 삽입

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

: 본인은이 주제를 부연 기사를 작성했습니다
+0

템플릿 필드를 사용하고 싶지 않지만이 코드를 통해 나를 보여줍니다. 감사 – Mehdi

관련 문제