Home > Archive > ASP .NET Webcontrols > April 2005 > DataList ERROR URGENT
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
DataList ERROR URGENT
|
|
| Chuck Yeager via DotNetMonster.com 2005-04-19, 4:00 am |
| I am having a dickens of a time here.
I have the following code in my code Behind:
NameSpace.MyListDB aCounty = new NameSpace.MyListDB();
myDropDownList.DataSource = aCounty.MyList(somestring);
myDropDownList.DataBind();
It calls this class and method which is a seperate class
.........................................
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
myCommand.ExecuteReader();
myConnection.Close();
return myCommand;
I have removed the try catch, etc code.
This is the error I get, anyone? Please
----------------
An invalid data source is being used for myDropDownList. A valid data
source must implement either IListSource or IEnumerable.
--
Message posted via http://www.dotnetmonster.com
| |
| Brock Allen 2005-04-19, 8:57 am |
| So what's the return value from aCounty.MyList(somestring);? As the error
says, it needs to be a collection of somesort.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> I am having a dickens of a time here.
>
> I have the following code in my code Behind:
>
> NameSpace.MyListDB aCounty = new NameSpace.MyListDB();
> myDropDownList.DataSource = aCounty.MyList(somestring);
> myDropDownList.DataBind();
>
> It calls this class and method which is a seperate class
> ........................................ myCommand.CommandType =
> CommandType.StoredProcedure;
>
> myConnection.Open();
> myCommand.ExecuteReader();
> myConnection.Close();
> return myCommand;
> I have removed the try catch, etc code.
>
> This is the error I get, anyone? Please
>
> ----------------
>
> An invalid data source is being used for myDropDownList. A valid data
> source must implement either IListSource or IEnumerable.
>
| |
| Chuck Yeager via DotNetMonster.com 2005-04-19, 4:02 pm |
| Brock,
Thanks for the response, I ended up doing the following: I was hoping to
do the same as I did in the datagrid and datalist where I seperated the
class for the Call to the stored procedure and the DropDownList.
-------------------------------
SqlConnection myConnection = new SqlConnection
(ConnectionDB.ConnectionString);
SqlCommand myCommand = new SqlCommand("aStoredProcedure", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
SqlDataReader sqlReader = myCommand.ExecuteReader();
countyDropDownList.DataSource = sqlReader;
countyDropDownList.DataBind();
myConnection.Close();
-------------------------------
I have no idea why the DataSource was erroring, but this at least satisfies
our DBA's concerns and we are using a stored procedure FOR EVERYTHING :(.
--
Message posted via http://www.dotnetmonster.com
|
|
|
|
|