views:

349

answers:

3

I'm hoping someone can help me with a question I have about images and GridView controls in ASP.Net 2.0.

I'm trying to put together a photo album application as a learning exercise which uses a GridView control with two columns. Column one will display the image (using an image column type) based on a URL held in the database I am using while column two will display some details about the image such as date, time, location, people etc.

This seems to works ok at the moment, however all the images are of the same size regardless of their orientation (portrait\landscape) which means that only some of the photos appear properly and no all crushed up. Is there a way to adjust the properties of the image column so that it will always show the photo correctly based on its orientation? Or a reduced size while maintaining the aspect of the image?

A: 

You can query the image properties, then change your picture container accordingly. This will need to be done in the RowDataBound event.

ck
Ignorant question, but do you have a code example of how to do this please?
Morrislgn
Forgot, rudely, yday to say thanks for the help
Morrislgn
A: 

I have no experience with the ImageField column type I assume you are using.

You could certainly just use a TemplateField and an img tag (without specifying width or height) to address this.

<asp:TemplateField>
    <ItemTemplate>
        <img src='<%# Bind("URLFromDB") %>' runat="server" />
    </ItemTemplate>
</asp:TemplateField>
HectorMac
Hi hector, thanks for your help
Morrislgn
A: 

Thanks for ur help