Click to See Complete Forum and Search --> : Programmically setting DataSourceID property of Repeater


tryston02
August 15th, 2005, 10:11 AM
Hey guys, I have a custom control I'm making that has a Repeater control in it and I need for people to be able to set the DataSourceID
property of the Repeater through a property of my Custom control.

I keep gettin this error:
Exception Details: System.Web.HttpException: The DataSourceID of 'rptDataMenu' must be the ID of a control of type IDataSource. A control with ID '<%=DataSourceID %>' could not be found.

Here's my property:
public string DataSourceID
{
get
{
return _dataSourceID;
}
set
{
_dataSourceID = value;
}
}

Here's where it is being called:
<asp:Repeater ID="rptDataMenu" runat="server" DataSourceID="<%= DataSourceID %>"> //errors out here!

Here is where it is being set:
<TACC:DataMenu ID="ctlDataMenu" runat="server"
BorderColor="#666666"
DataSourceID="OracleDataSource" />

Any Help would be greatly appreciated!!
Thanks!

cmiskow
August 15th, 2005, 11:42 AM
Wouldn't it just be easier to do this:


public string DataSourceID
{
get
{
return rptDataMenu.DataSourceID;
}
set
{
rptDataMenu.DataSourceID = value;
}
}

tryston02
August 15th, 2005, 11:54 AM
Wow, it worked!! Thanks man!!

take care!!

Chris