So you have some code running in your itemdatabound event handler and you are trying to do someting with e.item.dataitem but it keeps bombing out with errors because e.item.dataitem is nothing.
So, why is e.item.dataitem is nothing??
Answer: Because you are probably using a header or footer in your binding object. The header/footer will cause the itemdatabound event to fire, but there is no dataitem for them.
Check if the current row is the header or footer, and then you will have no issues with using e.item.dataitem.