By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

How to bind a CollectionList to a Dataset ????

P: n/a
Dear all,

Does anyone know how to bind a System.Collection.ArraysList object to a
Dataset ?

Thanks for your reply

Regards
Serge
Nov 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
What do you mean by "Bind to a DataSet"?

If you mean binding like binding data to a control to show data, then you
can't. DataSet is not a control, it only exists in memory, you do not see
it.

If you mean to use data in the collection to make a DataSet, then yes (but
not binding, it has specific meaning). Simply declare and instantiate a
DataSet, add table to it and add rows to table, then use the data to
populate the rows.

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:C3**********************************@microsof t.com...
Dear all,

Does anyone know how to bind a System.Collection.ArraysList object to a
Dataset ?

Thanks for your reply

Regards
Serge

Nov 22 '05 #2

P: n/a
HI,

That was exactly was I was doing, polulating the dataset with the content of
the arraylist collection. Actually after that work I bind the dataset to a
datagrid.

Actually the sequence I do is:
filling up my arrayList with some incoming data
Fill a datatable with rows of my arrayList data
Add the table to the dataset
Bind the dataset to a datagrid

I was thinking if tehre was a straight wayh to bind directly the arrayList
to the datagrid then ?

regards
serge
"Norman Yuan" wrote:
What do you mean by "Bind to a DataSet"?

If you mean binding like binding data to a control to show data, then you
can't. DataSet is not a control, it only exists in memory, you do not see
it.

If you mean to use data in the collection to make a DataSet, then yes (but
not binding, it has specific meaning). Simply declare and instantiate a
DataSet, add table to it and add rows to table, then use the data to
populate the rows.

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:C3**********************************@microsof t.com...
Dear all,

Does anyone know how to bind a System.Collection.ArraysList object to a
Dataset ?

Thanks for your reply

Regards
Serge


Nov 22 '05 #3

P: n/a
You cannot bind the ArrayList to the DataGrid but you can bind an IList.
Since ArrayList implements the IList interface you can cast the Arraylist
like so:
DataGrid.DataSource = (IList)ArrayList

Then all you have to do is set the DataGrid columns to any public properies
exposed by the items in your ArrayList and call the DataBind method of the
DataGrid.

It's just that easy...

--
Message posted via http://www.dotnetmonster.com
Nov 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.