grid view image column

Posted on 2009-12-21
Last Modified: 2012-05-08
I am trying to create a business class that contains a image property a,d a column that displays an image.  I am having trouble knowing what refernces I need and how to set this up.  I aphave seen samples of this done, but can't seem to locate code to support it.
Question by:FreightTrain
    LVL 15

    Expert Comment

    Do you want a property of Image type?

    Is better to store the path to your image and then get the image to show in your page.
    LVL 14

    Expert Comment

    by:Dhanasekaran Sengodan
    can u post sample code?

    Author Comment

    I am fine with storing the image path, I just don't understand how you bind a path to the grid so it displays the image.
    LVL 15

    Accepted Solution

    Check this sample
    <asp:ObjectDataSource ID="odsPics" runat="server" TypeName="PicsHandler" SelectMethod="GetPics"></asp:ObjectDataSource>
    <asp:GridView ID="gvTest" runat="server" DataSourceID="odsPics" AutoGenerateColumns="false">
            <asp:TemplateField HeaderText="Name">
                    <%# Eval("Name") %>
            <asp:TemplateField HeaderText="FileName">
                    <img src='<%# ResolveClientUrl("~/myPicsFolder/" + Eval("FileName").ToString()) %>'
                        alt='<%# Eval("Name") %>' />

    Open in new window


    Author Closing Comment

    Thank You!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now