我已将我的 html 模板加载到我的母版页中,然后将类别绑定到数据库。我用过这个编码。
<ul class="categories">
<li id="categoryItem">
<h4>Categories</h4>
<ul class="categories" id="categorylist">
<asp:Repeater ID="repCategories" runat="server">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="hyperCategories" runat="server"><%#Eval("CategoryName")%></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
</ul>
</li>
并尝试通过在 master.cs 页面上进行编码将此转发器绑定到我的数据库。
if (!IsPostBack)
{
DataSet ds = new ViewAction().GetAllProductCategoryData();
repCategories.DataSource = ds;
repCategories.DataBind();
}
但它显示的错误是
"The name repCategories does not exist in the current context"
为什么它显示这个错误帮助我解决这个问题。请