aspect ratio of an image in a gridview...

T

trint

I have a gridview displaying images from sql server. The images are
all different sizes, so I want to display each image at only 70 pixels
wide with the right perspective of the height. here is my code that
displays them at 50%, which isn't what i want:

<asp:GridView ID="GridView3" runat="server"
AutoGenerateColumns="False" AutoGenerateSelectButton="False"
CssClass="basix"
DataKeyNames="id" OnSelectedIndexChanged="getSelected3" Width="25%"
BorderColor="ForestGreen" ForeColor="Black">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton
ID="Linkbutton1" runat="server" CommandName="select" Text='<%# Eval
( "name" ) %>'></asp:LinkButton>
</ItemTemplate>
<ItemStyle
Wrap="True" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton
ID="Imagebutton1" runat="server" alt='<%# Eval ( "name" ) %>'
CommandName="select"
ImageUrl='<%#
DetectImagePath(Eval("thumbnail")) %>' Width="50%" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle
BackColor="White" Font-Bold="True" ForeColor="White" Width="25%" />
<AlternatingRowStyle
BackColor="LightGoldenrodYellow" ForeColor="Black" />
</asp:GridView>

Any help is appreciated.
Thanks,
Trint
 
G

Guest

Did you try specifying the width of the image like so:

Width="70"

If you do this without specifying the height, the image should maintain the
correct aspect ratio.
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top