473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding Multidimensiona l 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 multidimensiona l 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 2798


"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 multidimensiona l 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("Col umn1", typeof(Int32))) ;
dt.Columns.Add( new DataColumn("Col umn2", typeof(string)) );
....
DataRow dr ;
dr= dt.NewRow ();
dr["Column1"] = 1;
dr["Column2"] = "test";
...
dt.Rows.Add (dr);
DataGrid1.DataS ource =dt;
DataGrid1.DataB ind ();

---
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
6654
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 function (which was translated from Fortran code), among other heinous and numerous declarations, is this bit: static float bbuff; static int...
0
1257
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 array, but gives no further information than that. How would I set up a data binding to an array? Would this be a .net array? How is the array...
6
6547
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 in the collection and its properties (fields) in a datagrid? Maybe I can build a multidimensional array and bind that to the grid? Help is...
0
985
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
548
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 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...
1
396
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 with is binding a 1 dimensional array to a datagrid and that for whatever reason gives me the array element lengths rather than the values. Any...
0
1609
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 this with a Do loop, but was wondering if there is a better way. Thanks, Tom
4
2316
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 arrays or DataGrids to Databases but I can't quite get my head around what to do for datagrid to Array. A
9
4482
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 function: x = new int;
0
7478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.