Which method is better (performance-wise) if I have DataBoundControl such as GridView, Repeater, and/or DataList and I use the following method to display data:
Eval("ColumnName")
or handling the ItemDataBound or RowDataBound event like:
void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
// my code to display data here
}
I prefer the second one for code readability reason, but for performance reason, are they the same (or are they even the same thing)?
I also prefer the second version. It's easier for debugging and separation of html & code in my opinion.
According to this older doc, Improving .NET Application Performance and Scalability, it's more efficient (mentioned on page 297).
Eval might be faster(depends on the situatiuon, because it is also latebound and uses reflection), but via DataBound-Event it is more readable and more future-proof.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With