|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Output a Grid (Table) from a Collection?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 (spamhoneypot@rogers.com) 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. Show quoteHide quote "Spam Catcher" <spamhoneypot@rogers.com> 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 (spamhoneypot@rogers.com) "Nathan Sokalski" <njsokal***@hotmail.com> wrote in If I use a datagrid, don't I have to predefine the grid to be x columns news:#RCafB$EGHA.216@TK2MSFTNGP15.phx.gbl: > My suggestion is to not write your own code to do this, but to use > databinding (such as the DataList or DataGrid controls). wide? Same with a datalist? -- Stan Kee (spamhoneypot@rogers.com) 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! Show quoteHide quote "Spam Catcher" <spamhoneypot@rogers.com> wrote in message news:Xns9745EF293C1F9usenethoneypotrogers@127.0.0.1... > "Nathan Sokalski" <njsokal***@hotmail.com> wrote in > news:#RCafB$EGHA.216@TK2MSFTNGP15.phx.gbl: > >> 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 (spamhoneypot@rogers.com)
Show quote
Hide quote
"Nathan Sokalski" <njsokal***@hotmail.com> wrote in Funny - I never used the DataList because I liked the DataGrid's complexity 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. 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! ; ) I'll take a look at the DataList. My custom objects are all datalist compatible anyways. Thanks! -- Stan Kee (spamhoneypot@rogers.com) "Nathan Sokalski" <njsokal***@hotmail.com> wrote in news:etQV5pOFGHA.1760 @TK2MSFTNGP10.phx.gbl:> I believe you do have to predefine it for DataGrids (I have never used I used the datalist to output a multi-column datalist. Works great! Very > DataGrids because I found DataLists simpler, so I could be wrong about > that), but for DataLists you do not need to. simple to do too : ) -- Stan Kee (spamhoneypot@rogers.com) |
|||||||||||||||||||||||