Wednesday, January 21, 2009

My button doesn't work (Validation in a databound repeating control)

If you include validation controls in a templated control (GridView, Repeater, Accordion) make sure to set the ValidationGroup property of the validation controls to something that will resolve to a unique value for each item. If you don't do this, buttons may appear to stop functioning as the validator they are connected with is not the one you are working with in the given row.

An example of setting the ValidationGroup to something unique to each row might be:

ValidationGroup='<%# String.Format("RecordEdit_{0}",Eval("RecordID")) >%'

No comments:

Post a Comment