473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

IList or an IListSource error???

I am trying to populate a Listbox with the results of a query triggered from
a selection in a combo box:

private void cmbxCategory_SelectedValueChanged(object sender, EventArgs e)
{
string theCatId = cmbxCategory.SelectedValue.ToString();
var getSubCat =
from c in dataSet.Category // Category and
Subcategory are typed DataSets
from sc in dataSet.SubCategory
where theCatId == sc.S_CatId
select sc.S_Description;

lsbxSubCat.DataSource = getSubCat; ######
}

I'm getting the following exception at line #####
System.ArgumentException: Complex DataBinding accepts as a data source
either an IList or an IListSource.
at System.Windows.Forms.ListControl.set_DataSource(Ob ject value)
at
ExpenditureLINQDataSets.frmMain.cmbxCategory_Selec tedValueChanged(Object
sender, EventArgs e) in L:\Workspace\Visual Studio 2008\Projects\Expenditure
Analysis\ExpenditureLINQDataSets\ExpenditureLINQDa taSets\Form1.cs:line #####

I don't know if what I am trying to do is possible so I would appreciate
input on how to achieve my objective.
Nov 3 '08 #1
2 8686
The LINQ query will be either IEnumerable<Tor IQueryable<T- but
not IList. The simplest fix is probably to call the .ToList()
extension method:

sbxSubCat.DataSource = getSubCat.ToList();

Marc
Nov 3 '08 #2
Marc: thank you, that worked perfectly.

"Marc Gravell" wrote:
The LINQ query will be either IEnumerable<Tor IQueryable<T- but
not IList. The simplest fix is probably to call the .ToList()
extension method:

sbxSubCat.DataSource = getSubCat.ToList();

Marc
Nov 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tsteinke | last post by:
I noticed somthing. The native Array Types implement the IList interface. However they do not contain all the methods in the interfaces they implement. for example... int test=new int;...
3
by: Chris | last post by:
Hi, the specs for System.Array are : public abstract class Array : ICloneable, IList, ICollection, IEnumerable but I can't use any of the functions presented by IList in my code ...
3
by: Abbiento Morgan | last post by:
Someone know where can i find information and/or example (better in c#) for IList/IListSource interfaces for connect a my class to the DataGrid component via SetDataBinding method ?
4
by: KC | last post by:
Could some one explain to me the casting rules for sending generic lists, ex. List<Person>, to a function that accepts List<object>? I cannot get the following easy-cheesy app to work. I get the...
2
by: peter | last post by:
Hi, I try to bind a DataTable to a DataGrid, but I receive the following error-message : 'The IListSource does not contain any data sources'. I have no clue what the problem might be, as I...
7
by: BS | last post by:
Hello everybody I'm calling a webservice that returns complex data. The goal is to populate a datagrid with it. Using a loop for each record found ( such as For i = 0 To...
1
by: Paul | last post by:
Hi all, I'm trying to implement IList and keep getting an error when trying to implement GetEnumerator(). My class has a List<String> and I've been using its methods as return types for IList,...
1
by: Ryan Liu | last post by:
Hi, If a DataGrid.DataSource is an IList, not a DataTable, is there a way similar to dt.AcceptChanges(), dt.RejectChanges()? Thanks a lot! Ryan Liu
3
by: =?Utf-8?B?V2FsaWQ=?= | last post by:
Hello: I have migrated a site from IIS5 to IIS6. The site is configured and the we app is installed on the new IIS site. I can get to the web page but when I try to login, this is what I get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.