DataBinder.Eval Container.DataItem Performance Asp.Net
DataBinder.Eval Container.DataItem Method Performance In Asp.Net.
Using DataBinder.Eval method Slow down the performance of Asp.Net website or application noticeably.
It is mentioned in MSDN site as -
So one should avoid using this method as much as possible.
We use DataBinder.Eval method quite frequently in controls like GridView, Detailsview, DataList or Repeater to evaluate data binding expressions at run time because of simplicity like i used for Running Total in GridView.
Or in General context
Now as Eval method is performance hungry we can avoid using it by writing code like mentioned below.
Casting Container.DataItem as DataRowView explicitly performs better then Using Eval method.
Using DataBinder.Eval method Slow down the performance of Asp.Net website or application noticeably.
It is mentioned in MSDN site as -
"Because this method performs late-bound
evaluation, using reflection at run time, it can cause performance to
noticeably slow compared to standard ASP.NET data-binding syntax."
So one should avoid using this method as much as possible.
We use DataBinder.Eval method quite frequently in controls like GridView, Detailsview, DataList or Repeater to evaluate data binding expressions at run time because of simplicity like i used for Running Total in GridView.
1
decimal
rowTotal = Convert.ToDecimal
2
(DataBinder.Eval(e.Row.DataItem,
"Amount"
));
Or in General context
1
<%# DataBinder.Eval (Container.DataItem,
"Price"
) %>
Now as Eval method is performance hungry we can avoid using it by writing code like mentioned below.
1
<%# ((DataRowView)Container.DataItem)[
"FirstName"
] %>
Casting Container.DataItem as DataRowView explicitly performs better then Using Eval method.
0 comments: