Click to See Complete Forum and Search --> : Arraylist in a datagrid


dhanyavnair
October 7th, 2005, 02:11 AM
Hi ,

I have a bounded column in my datagrid which is an arraylist.while saving to the grid on a button click ,i am getting system.collection.arraylist , instead of the actual values in the arraylist.Could anybody please tell me how to display the values in the arraylist in the datagrid.My code is as follows:
Dim dtb New DataTable
Dim arl As New ArrayList
Dim drow As DataRow
Dim intcount as Integer

dtb= Get_Datatable(mydatagrid)

drow = dtb.NewRow

For intCount = 0 To mylisbox.listbox.ListItems.Count - 1
arl.Add(mylistbox.ListItems(intCount).Value)
Next
drow("ArrayList") = arl
dtb.Rows.Add(drow)

dtb.AcceptChanges()

mydatagrid.DataSource = dtb
mydatagrid.DataBind()


Note :Get_Datatable() is a function that will return the datatable of the datagrid

Thanks and Regards
Dhanya

jhammer
October 7th, 2005, 08:44 AM
You are mixing an ArrayList with a DataTable. I don't think you can do what you are trying, but maybe there is a way. I don't know.
I suggest an alternative way. Use a DataSet with two DataTables and a DataRelation between them. This will work very well. To simulate this behavior with an ArrayList seems impossible.

dhanyavnair
October 7th, 2005, 11:30 PM
--------------------------------------------------------------------------------

Hi ,

I have a bounded column in my datagrid which is an arraylist.while saving to the grid on a button click ,i am getting system.collection.arraylist , instead of the actual values in the arraylist.Could anybody please tell me how to display the values in the arraylist in the datagrid.My code is as follows:
Dim dtb New DataTable
Dim arl As New ArrayList
Dim drow As DataRow
Dim intcount as Integer

dtb= Get_Datatable(mydatagrid)

drow = dtb.NewRow

For intCount = 0 To mylisbox.listbox.ListItems.Count - 1
arl.Add(mylistbox.ListItems(intCount).Value)
Next
drow("ArrayList") = arl
dtb.Rows.Add(drow)

dtb.AcceptChanges()

mydatagrid.DataSource = dtb
mydatagrid.DataBind()


--------------------------------------------------------------------------------

i got a replay like this ,But i dont know how to create a dataset with to datatable and make relation can anybody give some example ,hoe to create it

You are mixing an ArrayList with a DataTable. I don't think you can do what you are trying, but maybe there is a way. I don't know.
I suggest an alternative way. Use a DataSet with two DataTables and a DataRelation between them. This will work very well. To simulate this behavior with an ArrayList seems impossible.



thanks and regards
Dhanya