Home All Groups Group Topic Archive Search About

Output a Grid (Table) from a Collection?

Author
6 Jan 2006 5:01 PM
Spam Catcher
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)

Author
8 Jan 2006 1:10 AM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

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)
Are all your drivers up to date? click for free checkup

Author
9 Jan 2006 4:30 AM
Spam Catcher
"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)
Author
9 Jan 2006 7:01 AM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

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)
Author
9 Jan 2006 4:17 PM
Spam Catcher
Show quote Hide quote
"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
> 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 (spamhoneypot@rogers.com)
Author
9 Jan 2006 9:58 PM
Spam Catcher
"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
> 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 (spamhoneypot@rogers.com)

Bookmark and Share