The following documentation topic should help you achieve your scenario. It explains how to programmatically add a validator to the edit field of
a GridBoundColumn, you can easily change that logic to attach your
custom code to the TextBox control when grid is in EditMode. Validation