Strange exceptions using FindControl after implementing master pages

Posted by inderio on Stack Overflow See other posts from Stack Overflow or by inderio
Published on 2010-04-09T18:09:37Z Indexed on 2010/04/09 18:13 UTC
Read the original article Hit count: 489

Filed under:
|

I have some simple repeater code given here:

<asp:Repeater ID="ResultsRepeater" runat="server" DataSourceID="ResultsDS">
 <HeaderTemplate>
 <table id="Results" class="data">
  <tr id="Header" runat="server">
   <th>Item</th>
  </tr>
 </table>
 </HeaderTemplate>
</asp:Repeater>

I used to be able to then access the repeater to get said header, as such:

HtmlTableRow header = ResultsRepeater.Controls[0].Controls[0].FindControl("Header") as HtmlTableRow;

After implementing master pages, I noticed my calls to header.InnerText and .InnerHtml throw exceptions, specifically:

'header.InnerHtml' threw an exception of type 'System.NotSupportedException'
'header.InnerText' threw an exception of type 'System.NotSupportedException'

Can anyone share what's going on with me? I am of course assuming master pages caused this, since it's the only thing I've changed besides minor updates (that should not affect this in any way).

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about master-pages