473,406 Members | 2,387 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,406 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 2781


"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.