I've created a user control web part and the code behind file contains the following:
using Microsoft.SharePoint;
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
namespace AnnouncementSlider1.ContentSlider
{
[ToolboxItemAttribute(false)]
public partial class ContentSlider : UserControl
{
string Qry = " <Where><Geq><FieldRef Name='Expires' /><Value
IncludeTimeValue='FALSE' Type='DateTime'>{0}</Value></Geq></Where>";
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) { DisplayAnnouncements();
}
}
private void DisplayAnnouncements() {
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
{
SPList list = web.Lists["Announcements"];
SPQuery query = new SPQuery();
query.RowLimit = 10;
query.Query = string.Format(Qry, DateTime.Now.ToString("yyyy-MM-dd"));
rep1.DataSource = list.GetItems(query).GetDataTable();
rep1.DataBind();
}
}
}
);
}
}
}
The control has the following item:
<asp:Repeater ID="rep1" runat="server">
When I build the solution, I receive an error stating:
Error The name 'rep1' does not exist in the current context
How should I remedy this error?