简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM