Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP.NET (Non-Forum Related)
 How do I change this behaviour ?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

laser
Advanced Member

Australia
3859 Posts

Posted - 27 November 2003 :  03:09:41  Show Profile
OK, I'm still at the clueless newbie stage, but I'm progressing. My .Net knowledge still consists of trying out code snippets until something works, but I'm moving pretty well.

I have been playing with some 4guys code at http://aspnet.4guysfromrolla.com/articles/011503-1.2.aspx but alarmingly I've just realised something .... let's say there are 9 images, the code (and other examples I've got) display in this fashion :

1 4 7
2 5 8
3 6 9

now what I REALLY need is :

1 2 3
4 5 6
7 8 9

Is there a way (hopefully easy) to make this happen ?

Nathan
Help Moderator

USA
7664 Posts

Posted - 27 November 2003 :  04:55:02  Show Profile  Visit Nathan's Homepage
The DataList object has a "RepeatDirection" property.

Nathan Bales
CoreBoard | Active Users Download
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 27 November 2003 :  05:06:08  Show Profile
Thanks Nathan

Any good .Net books you can recommend ?
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 27 November 2003 :  05:10:44  Show Profile
Use a DataTable (like a Recordset) to store the images, then you will have to bind the DataTable to a DataList with RepeatColumns set to 3 and use RepeatDirection as Nathan said.
You could also store the DataTable in the Cache object so that you don't have to re-populate it all the time!

The UK MkIVs Forum
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 27 November 2003 :  05:15:27  Show Profile
The property Nathan mentioned does the job great, but if I want to do paging (e.g. 34 images in a folder, but I want to see 10/page = 4 pages) would a DataTable or anything else be better for that ?

Sorry for the dumb questions, I have a bit of OOP experience in other languages, and I'm trying to learn .Net (the VB form)
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 27 November 2003 :  05:53:54  Show Profile
Not sure if the DataList has built in paging but you could get around it easily using a similar concept to ASP paging.
Get the DataTable.Rows.Count
Loop the DataTable.Rows until <= 10
Show next page link if DataTable.Rows.Count > 10
Start the loop on the next page at 11 in DataTable.Rows
and so on.....

Store the DataTable in the Session or Cache so it doesn't need to be re-populated on each page, you could actually store it in ViewState but be careful of the page size

The UK MkIVs Forum

Edited by - DavidRhodes on 27 November 2003 05:55:48
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 27 November 2003 :  05:59:33  Show Profile  Visit Nathan's Homepage
I would keep the page number in the query string and try to only grab the minimum I needed for that page. Be it records from a database or objects from the file system. Just too keep memory usage as trim as possible.

Nathan Bales
CoreBoard | Active Users Download
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 27 November 2003 :  06:00:59  Show Profile
no probs, paging is simple to write, but even better if it's built in.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.84 seconds. Powered By: Snitz Forums 2000 Version 3.4.07