HEEN
HEEN

Reputation: 4721

ID of Repeater is not coming in codebehind

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

Answers (2)

Davide Lettieri
Davide Lettieri

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

Irfan TahirKheli
Irfan TahirKheli

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

Related Questions