yes, exactly that. same applied for other controls i declared in the ascx
file.
here's a proper listing to help, on the page_load, where i'm setting the
datasource of the DataList is where the exception is thrown.
Although the DataListMain variable is declared, and the <asp

ataList> in
the ascx file, the refernece is always undefined. Is there anything i'm
missing from the delcaration in the host Page (aspx) file?
ASCX File
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="ItemDataList.ascx.cs" Inherits="MyNamespace.ItemDataList"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp

ataList id="DataListMain" runat="server" RepeatDirection="Horizontal"
RepeatColumns="4"
Width="100%" GridLines="Vertical">
<ItemTemplate>
Template item
</ItemTemplate>
</asp

ataList>
ASCX.CS
namespace MyNamespace
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for ItemDataList.
/// </summary>
public class ItemDataList : System.Web.UI.UserControl
{
public System.Web.UI.WebControls.DataList DataListMain;
private object ds;
/// <summary>
/// Gets or sets the data source.
/// </summary>
/// <value>The data source.</value>
public object DataSource
{
set { ds = value; }
get { return this.ds; }
}
private void Page_Load(object sender, System.EventArgs e)
{
// EXCEPTION THROWN HERE as
// this.DataListMain is UNDEFINED!!
this.DataListMain.DataSource = ds;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
it's such a simple thing i'm trying to, i don't know what's wrong though.
Thanks for your reply
--
TIA
Sam Martin
"" wrote:
> How did you find out that DataList1 is undefined?
> Did you set a breakpoint in your user control's Page_Load and examined
> DataList?
>
> Regards.
>
>