Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 581
  • Last Modified:

grid view image column

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.
0
FreightTrain
Asked:
FreightTrain
  • 2
  • 2
1 Solution
 
jorge_torizResearch & Development ManagerCommented:
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.
0
 
Dhanasekaran SengodanCommented:
can u post sample code?
0
 
FreightTrainAuthor Commented:
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.
0
 
jorge_torizResearch & Development ManagerCommented:
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">
    <Columns>
        <asp:TemplateField HeaderText="Name">
            <ItemTemplate>
                <%# Eval("Name") %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="FileName">
            <ItemTemplate>
                <img src='<%# ResolveClientUrl("~/myPicsFolder/" + Eval("FileName").ToString()) %>'
                    alt='<%# Eval("Name") %>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Open in new window

Pic.cs
PicsHandler.cs
0
 
FreightTrainAuthor Commented:
Thank You!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now