티스토리 뷰
DataBinder.Eval 매서드는 전송되거나 반환되는 인자를 알아내기 위해 .NET reflection을 사용한다.
ASP.NET페이지의 성능을 개선하기 위해 데이터 바인딩을 수행하는 동안 DataBinder.Eval의 사용을 자제하자.
DataBinder.Eval을 사용한 기존 방식
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "field1") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "field2") %></td>
</tr>
</ItemTemplate>
명시적인 캐스팅(Container.DataItem을 DataRowView로 캐스팅)은 .NET reflection을 사용하지 않기 때문에 보다 나은 성능을 낸다.
<ItemTemplate>
<tr>
<td><%# ((DataRowView)Container.DataItem)["field1"] %></td>
<td><%# ((DataRowView)Container.DataItem)["field2"] %></td>
</tr>
</ItemTemplate>
출처: http://dotnettipoftheday.org/tips/use-explicit-casting-instead-of-databinder.eval.aspx
'프로그래밍 > ASP.NET' 카테고리의 다른 글
상수 선언, const 와 readonly (0) | 2010.11.11 |
---|---|
ASP.NET 에서 ServerSide XmlHttp 호출 (0) | 2010.11.11 |
ashx session (0) | 2010.11.10 |
Enterprise Library - Data Access Application Block (0) | 2010.04.29 |
HTTP Handler (0) | 2010.02.02 |
ASP.NET 파일형식 (0) | 2010.01.29 |
ASP.NET을 이용한 엑셀(Excel) 파일 읽어오기 (0) | 2010.01.26 |
SmtpClient로 Gmail 계정으로 메일 보내기 (0) | 2009.12.14 |