Click to See Complete Forum and Search --> : DataSource Error on Custom Control


tryston02
August 17th, 2005, 08:19 AM
Hey guys, I have a custom control that contains a Repeater control in it. I need to be able to set the DataSource property of this custom control in the code-behind like so:

ctlDataMenu.DataSource = myDataReader;

However, I keep getting this error:
-----------------------------------------------
CS0029: Cannot implicitly convert type 'System.Data.OleDb.OleDbDataReader' to 'System.Web.UI.IDataSource'

Line 30: ctlDataMenu.DataSource = myDataReader;
------------------------------------------------

Here is my code:
---------------------
public IDataSource DataSource
/*
* ======================================
* PROPERTY: DataSource
* ======================================
* DESCRIPTION: Gets or Sets value of
* of the DataSource of the Repeater
* control (rptDataMenu).
*
* ======================================
*/
{
get
{
return (IDataSource)rptDataMenu.DataSource;
}
set
{
rptDataMenu.DataSource = value;
}
}
//========== END DATASOURCE ==========


Here is the file it is being called:
----------------------------------------------

...
myConnection.Open();

myDataReader = myCommand.ExecuteReader();
ctlDataMenu.DataSource = myDataReader;

ctlDataMenu.DisplayField = "OPERATOR";
ctlDataMenu.URLField = "OPERATOR";
ctlDataMenu.DataBind();

myConnection.Close();

...

Any help would be greatly appreciated! Thanks in advance!