All most every ASP.NET website I have seen, uses Databinder.Eval(Container.DataItem, "colum1") in repeaters to get the data passed in and show it on screen. The problem with Databinder.Eval is that it uses reflection to evaluate the item. This is time consuming and unnecessary, so instead, one should use casting to obtain the same effect. Try not to do it this way:
<asp:repeater id="rptAccounts" runat="server"> <itemtemplate> <%# Databinder.Eval(Container.DataItem, "colum1") %> <br /> </itemtemplate> </asp:repeater>
But use this one instead:
<asp:repeater id="rptAccounts" runat="server"> <itemtemplate> <%# ((BusinessObjects.Object)Container.DataItem).Column1 %> <br /> </itemtemplate></asp:repeater>This will also give you a compiler warning if the members of a class should change, andnot just runtime fail such as the first example. If you are not using businessobjects, but a DataTable, you can castto datarow and get the column right out of there like this:<asp:repeater id="rptAccounts" runat="server"> <itemtemplate> <%# ((DataRow)Container.DataItem)["Column1"] %> <br /> </itemtemplate> </asp:repeater> This both increases speed and makes the application more robust to runtime errors. A win-win situation:)
This will also give you a compiler warning if the members of a class should change, andnot just runtime fail such as the first example. If you are not using businessobjects, but a DataTable, you can castto datarow and get the column right out of there like this:
<asp:repeater id="rptAccounts" runat="server"> <itemtemplate> <%# ((DataRow)Container.DataItem)["Column1"] %> <br /> </itemtemplate> </asp:repeater>
This both increases speed and makes the application more robust to runtime errors. A win-win situation:)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.