DataSet to List<>
-
Hi! How can I take data from a dataset and populate a List<>()?
Illegal Operation
-
Hi! How can I take data from a dataset and populate a List<>()?
Illegal Operation
A List of what type? You could use Add to add an instance of type T to a List<T> You could use Add to add a DataSet to a List<DateSet> So what is it you want? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
A List of what type? You could use Add to add an instance of type T to a List<T> You could use Add to add a DataSet to a List<DateSet> So what is it you want? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
I need to create a list of type Dataset. Here is my code at the moment
List<> dsList = new List<>();
dsList.Add(payClass.GetPayItems());
How would I bind that list to a ListBox? P.S - I added to << and >> because when posting it removes it.
Illegal Operation
-
I need to create a list of type Dataset. Here is my code at the moment
List<> dsList = new List<>();
dsList.Add(payClass.GetPayItems());
How would I bind that list to a ListBox? P.S - I added to << and >> because when posting it removes it.
Illegal Operation
A ListBox can hold and show all kinds of items; by default, it calls ToString() on each of its items to visualize them. There is an alternative by turning the ListBox into "OwnerDrawn" mode, which means you set out to provide all the code required to paint one item, see the DrawItem event. If you were to bind a List<DataSet> to a ListBox, it would turn each DataSet into a single item in its collection; unless your DataSet has overridden its ToString() method, the net result would be something similar to the string "System.Data.DataSet" which I guess is not what you want. And painting a DataSet yourself would be a challenge. So I think you are tackling this the wrong way. I'm not so sure what it is you really want to achieve. PS: you can get proper < > & signs by using the little widgets above the editor box. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
A ListBox can hold and show all kinds of items; by default, it calls ToString() on each of its items to visualize them. There is an alternative by turning the ListBox into "OwnerDrawn" mode, which means you set out to provide all the code required to paint one item, see the DrawItem event. If you were to bind a List<DataSet> to a ListBox, it would turn each DataSet into a single item in its collection; unless your DataSet has overridden its ToString() method, the net result would be something similar to the string "System.Data.DataSet" which I guess is not what you want. And painting a DataSet yourself would be a challenge. So I think you are tackling this the wrong way. I'm not so sure what it is you really want to achieve. PS: you can get proper < > & signs by using the little widgets above the editor box. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
Luc, I have dataset that contains Items from my database. What I want to do is list all those payitems in listbox1 and then enable to user to add selecteditems to listbox2.
Illegal Operation
-
Luc, I have dataset that contains Items from my database. What I want to do is list all those payitems in listbox1 and then enable to user to add selecteditems to listbox2.
Illegal Operation
Well, AFAIK a DataSet can only contain DataTables; so maybe you have one or several DataTables that hold DataRows with such payitem information. The easy way of presenting one DataTable to a user is by using a DataGridView (assuming you are talking about a WinForms application). While I'm not an expert on DataTables and the like, I recently published my CP Vanity[^] article that uses both DataTable and DataGridView. I would suggest you read the MSDN documentation on the relevant classes, and have a look at my app. Assuming it looks like what you have in mind. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.