views:

212

answers:

1

I have a menu where I am setting the selected value dynamically.

Will I have better performance doing setting the value on a DataBound event or iterating over the menu in the PreRender event?

Would the performance characteristics be generalizable to all data bound controls (i.e. would it be different for a menu versus a gridview)?

Feel free to tell me why you would do this one way over the other, besides for performance reasons.

+2  A: 

If I understand what you are talking about here. My guess is that using the OnDataBound event is going to be slighly better performing than doing a iteration through the entire collection. At least when looked at in many scenarios.

The reasoning is that you already iterate through the items, and the OnDataBound event is triggered, therefore you use the internal processing to your advantage. If you then do your own iteration, you are going over the items again.

Mitchel Sellers