Reputation: 4721
I want to pull some data from the database into repeater, but I am not able to get the ID
of the repeater in code-behind. Please help what might be the possible reason ??
See my code though
<asp:Repeater ID="rptNews" runat="server">
<ItemTemplate>
<div class="Newsdiv">
<p class="Newspara"><a href="#"><%#Eval("title")%></a></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
</ItemTemplate>
</asp:Repeater>
In Codebehind:-
I want to call ID rptNews
in the codebehind, but it is not coming
Upvotes: 1
Views: 1005
Reputation: 326
Maybe you renamed the file or the class and the codebehind is no more "attached" to the aspx page.
Check in the aspx the directives at the beginning if the inherits value correspond to the name of class in the codebehind
Upvotes: 0
Reputation: 3662
One possible reason is control not defined in your designer.cs page. Check your designer.cs page see if this exists:
protected global::System.Web.UI.WebControls.Repeater rptNews;
If not then add it manually
Upvotes: 1