我刚刚开始一个新项目,我正在发生一些非常奇怪的事情。为什么我的Repeater在代码后面为空?
ASP.NET 3.5,VS2008。
我试过重建,关闭VS,删除一切,并再次从svn,但我不明白为什么在page_load下面的中继器为null。
我知道这将是一个头顶的时刻。帮帮我?
标记:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GalleryControl.ascx.cs" Inherits="Site.UserControls.GalleryControl" %>
<asp:Repeater ID="rptGalleries" runat="server">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<li>wqe</li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
代码背后
public partial class GalleryControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
rptGalleries.DataSource = new[] {1, 2, 3, 4, 5};
rptGalleries.DataBind();
}
}
设计师:
public partial class GalleryControl {
/// <summary>
/// rptGalleries control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater rptGalleries;
}
为什么我的中继空? F正在发生什么?
的参考页有这样的:
<ux:GalleryControl runat="server" ID="uxGalleryControl"/>
web.config中有这个(我以前从来没有这样做,但我的母版在抱怨找不到另一个用户控制)。
<add tagPrefix="ux" namespace="Site.UserControls" assembly="Site" />
很奇怪。你有没有检查你的.aspx.designer.cs文件的中继器控制? 也许由于某种原因,设计者并没有自动生成参考?我见过之前发生过。 – RPM1984 2010-06-10 00:50:06
是的,它在那里。更新的问题。 – 2010-06-10 00:54:19
我刚刚尝试创建一个具有相同效果的全新控件。引用它的页面上有一个DropDownList,这很好。 – 2010-06-10 00:58:48