MSTechnologies-help
Would you like to react to this message? Create an account in a few clicks or log in to continue.

improve performance with DataRowView instead of DataBinder.Eval method for Repeater or gridview

Go down

improve performance with DataRowView instead of DataBinder.Eval method for Repeater or gridview Empty improve performance with DataRowView instead of DataBinder.Eval method for Repeater or gridview

Post  Admin Fri Sep 12, 2008 10:35 pm

The DataBinder.Eval method uses .NET reflection to evaluate the arguments that are passed in and to return the results. Consider limiting the use of DataBinder.Eval during data binding operations in order to improve ASP.NET page performance.
Consider the following ItemTemplate element within a Repeater control using DataBinder.Eval:
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "field1") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "field2") %></td>
</tr>
</ItemTemplate>
Using explicit casting offers better performance by avoiding the cost of .NET reflection. Cast the Container.DataItem as a DataRowView:
<ItemTemplate>
<tr>
<td><%# ((DataRowView)Container.DataItem)["field1"] %></td>
<td><%# ((DataRowView)Container.DataItem)["field2"] %></td>
</tr>
</ItemTemplate>

Admin
Admin

Posts : 2
Join date : 2008-09-12

https://mstechnologies-help.board-directory.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum