![]() |
|
|
|||||||
![]() |
ASP Net - Output a Grid (Table) from a Collection? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi all,
Save I have a collection/arraylist, etc of 15, 20, 30 items. Does anyone have some neat code to output it into an abitrary grid table (i.e. 3x3, 4x4, 6x6, etc)? I know this is pretty trival to write - but I feel lazy today (plus I want to see what others have come up with). Thanks. -- Stan Kee () Spam Catcher |
|
|
|
|
#2 |
|
Posts: n/a
|
My suggestion is to not write your own code to do this, but to use
databinding (such as the DataList or DataGrid controls). This would be much more efficient, and will make it easier for you to manipulate the look of the output. If you are not familiar with databinding, don't let it scare you. Once you've seen a few examples, you'll love it. A good book that I would recommend if you aren't familiar with databinding is "ASP.NET Unleashed" by Stephen Walther, the book pretty much increased my knowledge of ASP.NET by ten-fold, and it gives plenty of examples, so you can see all the code involved. -- Nathan Sokalski http://www.nathansokalski.com/ "Spam Catcher" <> wrote in message news:Xns97437A458228Eusenethoneypotrogers@127.0.0. 1... > Hi all, > > Save I have a collection/arraylist, etc of 15, 20, 30 items. Does anyone > have some neat code to output it into an abitrary grid table (i.e. 3x3, > 4x4, 6x6, etc)? > > I know this is pretty trival to write - but I feel lazy today (plus I want > to see what others have come up with). > > Thanks. > > -- > Stan Kee () Nathan Sokalski |
|
|
|
#3 |
|
Posts: n/a
|
"Nathan Sokalski" <> wrote in
news:#RCafB$: > My suggestion is to not write your own code to do this, but to use > databinding (such as the DataList or DataGrid controls). If I use a datagrid, don't I have to predefine the grid to be x columns wide? Same with a datalist? -- Stan Kee () Spam Catcher |
|
|
|
#4 |
|
Posts: n/a
|
I believe you do have to predefine it for DataGrids (I have never used
DataGrids because I found DataLists simpler, so I could be wrong about that), but for DataLists you do not need to. You basically create what is called a Template. A Template is basically the same as other design code in ASP.NET, except the attributes that you want data entered for from a DataTable, Collection, SortedList, Array, or other collection type are entered using a special syntax rather than static text. Do a search for some examples, you shouldn't have much trouble with it, and trust me, it will save you a lot of time. Good Luck! -- Nathan Sokalski http://www.nathansokalski.com/ "Spam Catcher" <> wrote in message news:Xns9745EF293C1F9usenethoneypotrogers@127.0.0. 1... > "Nathan Sokalski" <> wrote in > news:#RCafB$: > >> My suggestion is to not write your own code to do this, but to use >> databinding (such as the DataList or DataGrid controls). > > If I use a datagrid, don't I have to predefine the grid to be x columns > wide? > > Same with a datalist? > > > -- > Stan Kee () Nathan Sokalski |
|
|
|
#5 |
|
Posts: n/a
|
"Nathan Sokalski" <> wrote in
news:: > I believe you do have to predefine it for DataGrids (I have never used > DataGrids because I found DataLists simpler, so I could be wrong about > that), but for DataLists you do not need to. You basically create what > is called a Template. A Template is basically the same as other design > code in ASP.NET, except the attributes that you want data entered for > from a DataTable, Collection, SortedList, Array, or other collection > type are entered using a special syntax rather than static text. Do a > search for some examples, you shouldn't have much trouble with it, and > trust me, it will save you a lot of time. Good Luck! Funny - I never used the DataList because I liked the DataGrid's complexity ; ) I'll take a look at the DataList. My custom objects are all datalist compatible anyways. Thanks! -- Stan Kee () Spam Catcher |
|
|
|
#6 |
|
Posts: n/a
|
"Nathan Sokalski" <> wrote in news:etQV5pOFGHA.1760
@TK2MSFTNGP10.phx.gbl: > I believe you do have to predefine it for DataGrids (I have never used > DataGrids because I found DataLists simpler, so I could be wrong about > that), but for DataLists you do not need to. I used the datalist to output a multi-column datalist. Works great! Very simple to do too : ) -- Stan Kee () Spam Catcher |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| New releases: Kubrick remastered, Pirates Of The Caribbean: At World's End & Four 2: Rise Of The Silver Surfer: Updated complete R1 DVD DB & info lists | Doug MacLean | DVD Video | 0 | 08-07-2007 08:40 AM |
| New releases: Monster House, You, Me And Dupree & Superman Collection: Updated complete downloadable R1 DVD DB & info lists | Doug MacLean | DVD Video | 1 | 09-19-2006 02:06 PM |
| New releases: Rent, Narnia & Spike Lee Joint Collection: Updated complete downloadable R1 DVD DB & info lists | Doug MacLean | DVD Video | 0 | 01-17-2006 05:44 AM |
| DVD Verdict reviews: NORTH AND SOUTH: THE COMPLETE COLLECTION and more! | DVD Verdict | DVD Video | 0 | 01-26-2005 10:33 AM |
| 204 R1 DVD-releases listed for week 9 (2004-02-23 / 2004-02-29) | DVDLister | DVD Video | 5 | 02-23-2004 02:10 PM |