newbie: q about repeater control and List<T>

  • Thread starter Thread starter Jeff
  • Start date Start date
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?
 
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?
 
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..
 
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
 
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
 
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
 
Back
Top