Search code examples
c#asp.netgridviewrepeaterfindcontrol

asp.net FindControl on unbound gridview or repeater


I have some user controls that contain asp.net GridViews and Repeaters and before binding data to them, i have to run some checks. I need to know whether certain controls exist in a TemplateField or ItemTemplate. Of course i cannot do .Row[0].FindControl, because there are no rows at this stage.


Solution

  • Before calling Databind, you cannot check any of the databound templates for controls.

    Not sure what your situation is, but perhaps you can loop through your data and validate there?