473,394 Members | 1,843 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,394 software developers and data experts.

Two dimensional array into datatable

Hi,

I would like to know how fill a datatable from a two dimensional array.

Any advice will be grateful.
--
Thanks a lot.
Regards.
Josema
Nov 16 '05 #1
3 10855
Hi Josema,

Is your size of array constant, or any of it's length?

If HEIGHT is constant:

object[,] yourArray;
DataRowCollection yourRows; // your DataTable's rows (eg. ID, VALUE)

int newId;
object[] itemArray=new object[2];
for(y=0; y<HEIGHT; y++) {
for(x=0; x<width; x++) {
newId=(y*HEIGHT)+x;
itemArray[0]=newId;
itemArray[1]=yourArray[y,x];
yourRows.Add(itemArray);
}
}

HTH
Marcin

PS: The Simplest, You can save values with (X, Y) as a DataTable
indices.
Hi,

I would like to know how fill a datatable from a two dimensional array.

Any advice will be grateful.

Nov 16 '05 #2
Hi,

AFAIK there is no way of doing that, the only way to go is iterate and
create/insert the items in the datatable

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Josema" <Je******@ocu.org> wrote in message
news:FA**********************************@microsof t.com...
Hi,

I would like to know how fill a datatable from a two dimensional array.

Any advice will be grateful.
--
Thanks a lot.
Regards.
Josema

Nov 16 '05 #3
Hi again,
You do not have to iterate in the second dimension ( the columns of the
row) , you could use the overloaded version of DataTable.Rows.Add(
objects[] )
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Nov 16 '05 #4

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

Similar topics

1
by: Martin Lindén | last post by:
I got this example written by David J Gottlieb. Which will not compile. I have previously read in the xml doc with myDataSet.ReadXML(Server.MapPath("bills.xml")) Then when i com to this...
3
by: ZeroVisio | last post by:
Hi, Is it possible to create two -dimensional array using ArrayList in C#? I know you can do one-dimensional array but i dont know how to do two-dimensional. in my case my number of columns...
4
by: rmorvay | last post by:
I have a requirement to search a multi-dimensional array for an item, then delete the item and "reset" the array so that their are no gaps in the resulting array. I have been trying to figure out...
3
by: j-in-uk | last post by:
Hi, I have a table with 2 columns and a one dimensional string array. I need to copy the string array to the table but I think I have to convert my string array to a 2dimensional array first with...
5
by: PJ6 | last post by:
I've chosen to store the contents of a grid in a two dimensional object array. As the size of the grid changes, so must the array. I was surprised to find out that the niceties I'm used to with one...
4
by: De_Kabal | last post by:
I'm trying to bind a 12x16 array to a repeater to display the information in a table to have certain format. Right now all it does is display all the array elements on individual rows. Does anyone...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
3
by: gihope | last post by:
Can anyone tell me why I am not allowed to bind a two or multi dimensional array to GridView and possibly suggest how they would deal with similar scenarios? The array is simply a two dimensional...
5
by: nelly0 | last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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...

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.