Thumbnail image inside a Gridview

Posted on 2007-08-08
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
    LVL 14

    Expert Comment

    Create the thumbnail when you are uploading the image. and save it another location. and load the same in grid view.
    LVL 8

    Expert Comment

    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 />
    LVL 1

    Author Comment

    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
    LVL 1

    Accepted Solution

    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">

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    This video teaches users how to migrate an existing Wordpress website to a new domain.

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now