[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Thumbnail image inside a Gridview

Posted on 2007-08-08
Medium Priority
Last Modified: 2013-11-19
What I have created is a Gridview displaying images set aside in a folder, each images is pull according to sql database info.

Once I get it to display, it will size the image according to it's native size and I am having a hard time reducing the image automatically.

Is there a simple way in generating a thumbnail inside a Gridview?

I am using ASP.NET 2.0 with C#.

Question by:bri_stc
  • 2
LVL 14

Expert Comment

ID: 19658724
Create the thumbnail when you are uploading the image. and save it another location. and load the same in grid view.

Expert Comment

ID: 19658774
How about the idea, place asp image control inside the grid as a template column. You can specify the height and widith in that.

<asp:Image ID="" CssClass=" " Height = "" Width ="" Width />

Author Comment

ID: 19671990
This is the code i use to retrieve the actual pictures:

<asp:ImageField DataImageUrlField="PictureURL" DataImageUrlFormatString="~/images/{0}" HeaderText="Photos" >

I try simply adding Height and Width, it will give me a error....   Not sure about the CssClass

Accepted Solution

bri_stc earned 0 total points
ID: 19671996
Here is the complete code for the gridview and sql connection

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#666666" BorderStyle="Solid" BorderWidth="3px"
            CellPadding="4" DataKeyNames="PictureID" DataSourceID="SqlDataSource1" ForeColor="Black"
            GridLines="Horizontal" Height="177px" PageSize="5" Width="399px">
            <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                <asp:ImageField DataImageUrlField="PictureURL" DataImageUrlFormatString="~/images/{0}"
                    HeaderText="Photos" >
                <asp:BoundField DataField="PictureURL" HeaderText="Image" SortExpression="PictureURL" />
                <asp:BoundField DataField="UploadedByMemberName" HeaderText="Uploaded by" SortExpression="UploadedByMemberName" />
                <asp:BoundField DataField="Notes" HeaderText="Comment" SortExpression="Notes" />
            <RowStyle BackColor="#CC441B" />
            <EditRowStyle BackColor="White" />
            <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#CC441B" ForeColor="Black" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#CC441B" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="#CC441B" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PhotoDataBase %>"
            SelectCommand="SELECT [PictureID], [UploadedByMemberName], [Notes], [PictureURL] FROM [Gallery] ORDER BY [PictureID] DESC">

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month19 days, 21 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question