newbie: q about repeater control and List<T>

J

Jeff

hi

asp.net 2.0

I have a list, List<Car> which I want displayed in a Repeater control. Each
line of the repeater contorl should display 3 different pictures.

The problem is that these 3 different pictures represent 3 different records
in the Database. So in the ItemDataBound method I can only reach one of
them. I should instead access 3 car objects from that method to make it
correct...

e.Item.DataItem holds the reference to one of the Car objects, I need
reference to 3 from that method.. or maybe solution is in another method,
not ItemDataBound

anyone got any tips?
 
J

Jeff

yeah, but I hoped to avoid doing that because then I must make changes to
the DAL and BLL. I have created custom entities in both the DAL and BLL.

Each item in the ItemDataBound represent an entity.

Som other places in the website just one entity is needed (not displaying 3
in a row) so I hope to avoid doing that approach (altertering sql select)
but maybe changing my sql query is the only thing I can do to solve it...

any suggestions?
 
J

Jeff

i think I got an solution, I don't use a repeater control. instead I just
hardcode the image controls... I've looked in the spec and it says they want
3 pictures displayed on each row.. and rows are limited to 3.. so that means
9 picture controls on the page... this is not a good solution but I cannot
figure out anything better at this moment..
 
P

Peter

Mark said:
Why have you done that...?


The whole point about n-tier architecture is that each of the tiers
doesn't need to know how the other tiers do things, only what
interface they publish. So your BLL / DAL really shouldn't care what
your database has to do in order to return a DataSet... Your BLL asks
your DAL to fetch a DataSet from the database which it will then use
to present that data to the UI layer - how the database actually does
that is of no concern...

What is your reasoning about returning a "DataSet" from the DAL to the
BLL. Now you're telling the BLL that there are tables, and rows, and
columns...

Wouldn't it be better to hide these details and return "cars"?


/Peter
 
P

Peter

Mark said:
Because that appears to be the architecture that the OP is using.


That's correct.


Why?

Well I thought that as the problem was about "cars", it was "cars" that
the BLL should worry about. So it should deal with collections of
"cars" for example. It shouldn't worry or know about database tables or
rows or columns.

I thought that the DAL should know about DataSets, and create or obtain
them from the database, and then supply the BLL with the relevant
"cars".

Maybe other "cars" come from a datasource which reads from xml files,
or from a web-service....? Then the "DALs" for these would handle the
problem of reading from XML or contacting the webservice - hiding these
details and the actual persistance type from the BLL, abd returning
"cars", not xml or webservice return values.

Or is this naive?

/Peter
 
H

Hans Kesting

It happens that Jeff formulated :
yeah, but I hoped to avoid doing that because then I must make changes to the
DAL and BLL. I have created custom entities in both the DAL and BLL.

Each item in the ItemDataBound represent an entity.

Som other places in the website just one entity is needed (not displaying 3
in a row) so I hope to avoid doing that approach (altertering sql select) but
maybe changing my sql query is the only thing I can do to solve it...

any suggestions?

And what if you still retrieve that List<Car> from the database, but
then change it (for this screen) into a List<CarWith3Images>?

- get each unique car in the original list
- create and initialize a new CarWith3Images
- and find and add the other images for the same car (with a max of 3)

Hans Kesting
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top