Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Output a Grid (Table) from a Collection?

 
Thread Tools Search this Thread
Old 01-06-2006, 05:01 PM   #1
Default 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 ()


Spam Catcher
  Reply With Quote
Old 01-08-2006, 01:10 AM   #2
Nathan Sokalski
 
Posts: n/a
Default Re: Output a Grid (Table) from a Collection?
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
  Reply With Quote
Old 01-09-2006, 04:30 AM   #3
Spam Catcher
 
Posts: n/a
Default Re: Output a Grid (Table) from a Collection?
"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
  Reply With Quote
Old 01-09-2006, 07:01 AM   #4
Nathan Sokalski
 
Posts: n/a
Default Re: Output a Grid (Table) from a Collection?
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
  Reply With Quote
Old 01-09-2006, 04:17 PM   #5
Spam Catcher
 
Posts: n/a
Default Re: Output a Grid (Table) from a Collection?
"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
  Reply With Quote
Old 01-09-2006, 09:58 PM   #6
Spam Catcher
 
Posts: n/a
Default Re: Output a Grid (Table) from a Collection?
"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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46