How can I show 2 records beside each other?

W

William Buchanan

Hi folks

I want to show 2 records on a page side by side. Each record has an image
which will be displayed and a bit of text.

How can I do this?

Thanks

Will
 
W

William Buchanan

Thanks for the reply.

I have a table with around 100 records. I want to show the records 2 at a
time.

They need to be beside each other since each one has a large image
associated with it (so each record will occupy half of the page).

PS. I am using ASP.NET 2.0

Will
 
W

William Buchanan

I have looked into the repeater object. As far as I could see, you can bind
it to the data of the current record only.

Are you saying it is possible to bind it to the next record as well?
 
E

Erik Funkenbusch

I have looked into the repeater object. As far as I could see, you can bind
it to the data of the current record only.

Are you saying it is possible to bind it to the next record as well?

Stop and think for a moment. How exactly could it be a "repeater" control
if it could only bind to one record?
 
G

Guest

Hi William,

You can use either Repeater or DataList to do it. Either one can be bound
with data source (DataSource, ObjectDataSource, or DataTable/DataSet which
retireve data). Repeater or DataList will loop thru data records for you and
you can give its layout in a more flexible style (compare to GridView and
DataGrid).

HTH

Elton Wang
 
W

William Buchanan

That is not what I said. If you read my posting again I said "current
record".

The actual problem is that I want it to bind to the current and the next
record.
 
W

William Buchanan

Thanks for the reply. I am missing something so please bear with me!

I can see how the repeater can be used to repeatedly display all records in
a table (as can a datalist). However, I only want to see 2 records at a
time. This means that I need to show the first 2 records, then when I click
"Next" it will show the next 2 records, and so on.

I know this can be done through lots of code, but I was hoping that there
would be some way of doing it by using the data components.

Will
 
E

Erik Funkenbusch

That is not what I said. If you read my posting again I said "current
record".

This is incorrect. The repeater binds to as many records as you have in a
dataset. If your dataset contains one record, it will bind to the current
record. If it contains two records, it will bind to two records, etc..
The actual problem is that I want it to bind to the current and the next
record.

Easily solveable by using a paging algorithm. Sajarki points you to one
example, another is here:

http://weblogs.sqlteam.com/jeffs/archive/2004/03/22/1085.aspx

This returns as many records as you want at a time, and lets you set the
"next" and "previous" controls to get the next or previous set.
 
W

William Buchanan

Thanks

Erik Funkenbusch said:
This is incorrect. The repeater binds to as many records as you have in a
dataset. If your dataset contains one record, it will bind to the current
record. If it contains two records, it will bind to two records, etc..


Easily solveable by using a paging algorithm. Sajarki points you to one
example, another is here:

http://weblogs.sqlteam.com/jeffs/archive/2004/03/22/1085.aspx

This returns as many records as you want at a time, and lets you set the
"next" and "previous" controls to get the next or previous set.
 
J

Juan T. Llibre

What you're looking for is Paging.
It doesn't take much coding to implement it.

The reference you were given :
http://aspnet.4guysfromrolla.com/articles/081804-1.aspx
is an excellent guide.

There's other approaches, like :
http://www.411asp.net/func/content?tree=411asp/tutorial/howto/database/displayr/pagingre&id=4628710
and
http://www.vbdotnetheaven.com/Code/Sept2003/2173.asp

Here's a ready-made PagingRepeater control, complete with its free code,
which you could probably easily adapt to your needs :

http://www.codeproject.com/aspnet/pagingrepeater.asp

You'll need to join the Code Project to download the code,
but it's free and they don't bug you with spam.

Good luck!
 
W

William Buchanan

Great - thanks for all your help.

Will


Juan T. Llibre said:
What you're looking for is Paging.
It doesn't take much coding to implement it.

The reference you were given :
http://aspnet.4guysfromrolla.com/articles/081804-1.aspx
is an excellent guide.

There's other approaches, like :
http://www.411asp.net/func/content?tree=411asp/tutorial/howto/database/displayr/pagingre&id=4628710
and
http://www.vbdotnetheaven.com/Code/Sept2003/2173.asp

Here's a ready-made PagingRepeater control, complete with its free code,
which you could probably easily adapt to your needs :

http://www.codeproject.com/aspnet/pagingrepeater.asp

You'll need to join the Code Project to download the code,
but it's free and they don't bug you with spam.

Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top