我收到消息:
编译器错误消息:CS1061
我创建了一个asp.net网站。我有一个中继器,它必须在其内部绑定另一个中继器。我将此代码用于中继器:
<asp:Repeater runat="server" ID="productswiperrepeater" OnItemDataBound="OnItemDataBound">
<ItemTemplate>
<asp:Repeater runat="server" ID="productswiperrepeaterbuttons">
<ItemTemplate>
<li>
<button type="button" class="btn slide_active_btn" data-index='<%# Container.ItemIndex+1 %>'><%# Eval("name") %></button>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</ItemTemplate>
</asp:Repeater>
此代码为后端:
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
int hidddenid = Convert.ToInt32((e.Item.FindControl("hidddenid") as HiddenField).Value);
Repeater navigationimage = e.Item.FindControl("productswiperrepeaterimages") as Repeater;
Repeater navigationchildren = e.Item.FindControl("productswiperrepeaterbuttons") as Repeater;
string command = "select id, image, name, sliderbackground, sliderimage from Categories where idparent = {0} and not name = 'متوقف شده' and sliderimage is not null";
navigationimage.DataSource = databinding.GetData(string.Format(command, hidddenid));
navigationimage.DataBind();
navigationchildren.DataSource = databinding.GetData(string.Format(command, hidddenid));
navigationchildren.DataBind();
}
}
它在我的本地主机上运行良好,但是当我将其上传到主机时,收到错误消息:
编译器错误消息:CS1061:'default_aspx'不包含 'OnItemDataBound'的定义,没有扩展方法 'OnItemDataBound'接受类型为'default_aspx'的第一个参数 可以找到(您是否缺少using指令或程序集 参考?)
有人知道我的代码或主机有什么问题吗?
答案 0 :(得分:0)
部署时,您的代码隐藏文件(.cs
)将编译为dll。确保在发布时,这些dll文件也被复制过来。这也意味着您发布的项目不应包含任何.cs或.designer.cs文件。或尝试在...中使用重命名方法...