How to put a collection into dataset?

B

Brett Romero

I use a method that returns either a dataset or a collection depending
on the method called. Since no database is involved at the layer I'm
working, I can't use a data adapter's fill method to fill these results
into my local dataset. How can I get these results into the local
dataset?

I need the results place into a dataset to allow working with
DataGridTableStyle for grid formatting.

Thanks,
Brett
 
T

tdavisjr

Loop through the collection and dynamically create a DataTable in
memory, then you can stick that DataTable in you dataset if you need it
in there.
 
N

Nicholas Paldino [.NET/C# MVP]

Brett,

You shouldn't have to get the results into a dataset to allow wirking
with the DataGridTableStyle... It should be able to work with whatever
BindingManager is being used to get the data from.

If you want to populate a data set, then it is easy, all you have to do
is get the appropriate table, and call the Add method on the
DataRowCollection returned to you from the Rows property.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top