Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Binding Multidimensional Array to DataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
epigram - 15 Jul 2005 22:15 GMT
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.
societopia.net - 16 Jul 2005 00:02 GMT
> 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
[quoted text clipped - 8 lines]
>
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.