You could just include the ItemOrder field by default (when creating the custom table) and already have your sort field setup for you. This will automatically pick the next largest number which should follow very closely with your ItemID (unless you reorder them). Also, this will allow you to resort using the out of the box functionality vs. having to code for it. If you don't choose this way, I'd highly recommend a global handler as Sandro mentioned.