473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

aspect ratio of an image in a gridview...

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

Apr 27 '07 #1
1 2295
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.

--
Thanks,
Page Brooks
www.explosivedog.com
"trint" wrote:
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

Apr 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ruby Tuesday | last post by:
I have a section(185pixelsx 185pixels) in my web page to display an image that is stored in a directory. Using php, how do you resize so if: the image dimension is smaller(width and height is...
5
by: Ron Vecchi | last post by:
I know the math I need to perform on width and height to keep an aspect ratio but where and how would I implement keeping a set aspect ratio on a form when a user resizes it. Override OnResize?...
5
by: Arthur Hsu | last post by:
Hello, I have an ImageButton that refers to an external image. How can I keep that image's aspect ratio when I set the ImageButton's size to 120x120? TIA, Arthur
2
by: Carl Gilbert | last post by:
Hi I am looking for either a component or technique to allow me to do the following: * Provide a panel with a background image * Resize the image to best fit the panel to maintain aspect...
2
by: Farce Milverk | last post by:
Hi, I'm looking for an algorithm to resize an image of arbitrary size to a "fixed" / required width and height. For example, my application requires that images be no larger than 440 pixel...
0
by: mharness | last post by:
Hello All, Does anyone know how to dynamically change the width and height properties of an image in a datalist in order to maintain the original aspect ratio? I've managed to do this with a...
5
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, If I create a form in Java with controls like Panels, textboxes... when I stretch/shrink the form, all the controls can grow/shrink - along with the text contained in the textboxes. This...
3
by: Danny Ni | last post by:
Hi, I am looking for a way to display images with different aspect ratio into frames with fixed width and height, the problem is some images will look distorted if they are forced into fixed...
2
by: alag20 | last post by:
Hi, How can I print an while preserving its aspect ratio. Currently I am using the code below. private void PrintClicked(object sender, EventArgs e) { PrintDocument doc =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.