|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataList ERROR URGENTI 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. 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 Show quoteHide quote > 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. > 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 :(.
Uncheck Checkboxes
Repeat web controls in ASPX page Dynamic loadcontrol of ascx with dll not in bin path GridView Rows collection refresh within an event Open New Window Server Side Developing .NET Custom Web Control for use in ASP & ASP.NET pages DataGrid Question - asp:Hyperlink AddHandler / Remove Handler? How do you populate the Dropdown in IE Web Controls? Creating a 3 State Rollover Button |
|||||||||||||||||||||||