I've noticed that I've been doing more and more during the OnItemDataBound event in order to dynamically set properties of elements in a DataGrid. For instance, this one grid I have has around six or more buttons in each row that need to be made visible or
have other properties set based on the current DataItem. As a result the code for that event handler is getting really long (over two scroll-wheel's worth). My question is how much is too much and/or how else could it be done? I'm not so much interested in
making little helper methods to clean up the OnItemDataBound event (although it would probably help), but more interested in reducing the amount of processing that gets done during the binding. Like, somehow already have a lot of it figured out (through better
design) before binding it to the grid. Or, would just keeping the processing in OnItemDataBound event be more effeicient? I guess the question might boil down to: "Is it any more efficient to process data prior to binding it to a control, or is it best to
let the control's binding event do just the processing it needs to display the items correctly?" Any thoughts/opinions welcomed. Thanks
thwarg
Member
320 Points
64 Posts
Abusing OnItemDataBound?
Nov 21, 2003 02:04 PM|LINK