detect missing images

  • Thread starter Thread starter five40
  • Start date Start date
F

five40

I have an aspx page that returns a list of products in a datagrid. The
datagrid contains a template which contains a link to an image. The
image name is stored in the database. The actual images are stored in
a folder on the server.

I am looking for a way to create a variation of this page that ONLY
shows the items that are missing images.

Any ideas are greatly appreciated.

Thanks!
 
You could use System.IO.File.Exists to check for file existance. Else what
is the exact problem ?
 
I'm not sure how to integrate that into the code with the datagrid.
The name of the image is stored in the database and I access it
through a template column with like this:

<asp:Label ID="lblImagePath" runat="server" Visible="false" Text='<%#
DataBinder.Eval(Container.DataItem, "ProductImage") %>'> </asp:Label>

How do I incorporate "System.IO.File.Exists" into the datagrid? And
how do I make the visibility of the rows dependent on the outcome?

I am new at this and learning so thanks for your patience.
 
My approach would be just to suppress unwanted lines from the data source
(either by removing uneeded lines or by filtering on a boolean columns that
tells if the image is there).

This column could be added and filled just before rendering the grid but a
later time it could be even something that is stored in your db (I assume
that you know earlier that there is no image, for example because no image
was uploaded in the product creation form ?)
 
Back
Top