We help IT Professionals succeed at work.

How to display the values in a Grid from an arraylist

vmandem asked
Medium Priority
Last Modified: 2010-04-16
Hi, I'm having an arraylist and in the arraylist I have values for 24 hours in a day. For each Unit(which is a primary field) I have multiple column values for each hour. When I fill the datable and to dataset
and bind the dataset I get displayed vertically instead of horizontally how to flip the values and display it.

Here is how it looks like:

Hour Ending1
       Unit1,colum1,column2 values
Hour Ending 2
      Unit1,column1,column2 values
...SO on
Hour Ending 24
     Unit1,column1,column2 values.

Here is how I want:

Hour Ending1                                Hour Ending2    
Unit1,column1,column2 values        Unit1,column1,column2 values and
So on.. Hour Ending24.

comments:I'm currently doing this from the array list:

 ArrayList umarray = m_clsum.Build1(um); //<--I get arraylist from class.

                //System.Data.DataSet ds = new System.Data.DataSet("umarray");
                             DataSet ds = new DataSet();
                Type myType = umarray[0].GetType();
                System.Reflection.PropertyInfo[] api = myType.GetProperties();

                foreach (System.Reflection.PropertyInfo pi in api)
                System.Data.DataRow dr = null;
                foreach (object obj in umarray)
                    dr = dt.NewRow();
                    foreach (System.Data.DataColumn myColumn in dt.Columns)
                       dr[myColumn.Caption] = myType.GetProperty(myColumn.Caption).GetValue(obj, null);
                int i;
                int hour = DateTime.Now.Hour;
                for (i = 0; i <= (ds.Tables[0].Columns.Count - 1); i = i + 1)
                    ds.Tables[0].Columns[i].ColumnName = ds.Tables[0].Columns[i].ColumnName + hour;
                string colname;
                colname = ds.Tables[0].Columns[15].ColumnName;


Thanks VM
Watch Question

Most Valuable Expert 2012
Top Expert 2008
Recreate the DataTable with the rows as columns.


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.