473,326 Members | 2,813 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,326 software developers and data experts.

Binding Multidimensional Array to DataGrid

Well, conceptually this is what I want to do. I was hoping to use an
ArrayList to build a (dynamic) array of string arrays, and then bind the
ArrayList object to a DataGrid. I can do that, but it doesn't give me the
results that I wanted. Is there a way to successfully do this? I even
tried to bind a multidimensional array (string [,]) to a DataGrid, but an
exception is thrown with the message "Array was not a one-dimensional
array". I'm using the ArrayList simply as a convenient data structure (like
a table) to store the results of some calculations I am making. I can take
another approach if someone has a suggestion. Any help would be much
appreciated.

Thanks.
Nov 19 '05 #1
1 2778


"epigram" wrote:
Well, conceptually this is what I want to do. I was hoping to use an
ArrayList to build a (dynamic) array of string arrays, and then bind the
ArrayList object to a DataGrid. I can do that, but it doesn't give me the
results that I wanted. Is there a way to successfully do this? I even
tried to bind a multidimensional array (string [,]) to a DataGrid, but an
exception is thrown with the message "Array was not a one-dimensional
array". I'm using the ArrayList simply as a convenient data structure (like
a table) to store the results of some calculations I am making. I can take
another approach if someone has a suggestion. Any help would be much
appreciated.

Thanks.


A DataTable is equivalent in function to a multi-dimensional array and it
works nicely with the DataGrid:

DataTable dt = new DataTable();
dt.Columns.Add( new DataColumn("Column1", typeof(Int32)));
dt.Columns.Add(new DataColumn("Column2", typeof(string)));
....
DataRow dr ;
dr= dt.NewRow ();
dr["Column1"] = 1;
dr["Column2"] = "test";
...
dt.Rows.Add (dr);
DataGrid1.DataSource =dt;
DataGrid1.DataBind ();

---
www.societopia.net
Nov 19 '05 #2

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

Similar topics

9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
0
by: David Steward | last post by:
When looking at the help files for datagrid I see a lot of information for how to data bind the datagrid to a database. The help information mentions that data binding can be done also to an...
6
by: Morten | last post by:
Hi! I've made my own webservice which returns a collection of objects with 4 properties (or fields when they get returned from the webservice...). Is there an easy way to display each object...
0
by: EQ | last post by:
Could any one help on how to bind a multidimensional array to datagrid array [3,4 This should be 3 rows and 4 columns ,Dont know if its correct Thanks
0
by: epigram | last post by:
Well, conceptually this is what I want to do. I was hoping to use an ArrayList to build a (dynamic) array of string arrays, and then bind the ArrayList object to a DataGrid. I can do that, but it...
1
by: Ed | last post by:
Hi there, I have a two dimensional array which I would like to bind to a datagrid, however I've spent all afternoon googling for a solution and I can't find one anywhere. The best I've come up...
0
by: tshad | last post by:
I have a multidimensional array (string ) that I need to put into a datatable. I was going to move it into a DataTable and then bind that to a DataGrid. String has the column titles. I can do...
4
by: Alan Gillott | last post by:
Is it possible to bind a Datagrid to a 2 dimentional Array? Or even a Collection? I know Linq can in vb2008 but I don't want to download 2008 just yet. Lots of examples binding text boxes to Id...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.