Results 1 to 4 of 4

Thread: Datagrid and Images

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260

    Datagrid and Images

    Anyone have an easy method for inserting a picture (based on a product number) into a datagrid column. I assume it needs to be a templet with an image control set in the input frame. But can this string be built in a data class and databind it?

    gollnick
    William E Gollnick

  2. #2
    Hyperactive Member kayos's Avatar
    Join Date
    Apr 2004
    Location
    Largo, Florida
    Posts
    306

    Re: Datagrid and Images

    yes, when you insert the asp:Image control to your template click on "Data Bindings", once youve done that choose the column of your class that the file name is associated to. in the box below that is the format string box. that is where you put something like "/images/{0}". that will bind your file name to the {0} part and will show up on the page.


    If this post helps, please RATE MY POST!

    Using Visual Studio 2005 SE

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260

    Re: Datagrid and Images

    Thanks. Do you mean select the ImageUrl .. Then Container and inside that the DataItem .. then in the format .... "/images/{0}" ???

    Would you have an example ??

    Thanks .. gollnick
    William E Gollnick

  4. #4
    Hyperactive Member kayos's Avatar
    Join Date
    Apr 2004
    Location
    Largo, Florida
    Posts
    306

    Re: Datagrid and Images

    yes, it would be in the ImageUrl part of the <asp:Image> tag.

    it would look something like this:
    <asp:Image runat="server" ID="Img1" ImageUrl="<%# Bind("ImageLocation", "/images/{0}") %>">

    that would be inside your <itemTemplate> tag for that column of the gridview.


    If this post helps, please RATE MY POST!

    Using Visual Studio 2005 SE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width