This is a migrated thread and some comments may be shown as answers.

Show image in the grid

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 11 Feb 2009, 03:23 AM
Now I band my grid with a database table-product table ,and every product records have self image,but I just save the image name in the table and the images are stored in server hard disk.
How to show image in the grid rows for every record,now I use this code DataTextFormatString="<img src='YourImageUrl' />" to show image in my grid,it can not work well,just show same image every rows.

Thx.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Feb 2009, 11:14 AM
Hello Tommy,

You can try out the following code to set the images for various rows in a grid:
aspx:
<telerik:GridTemplateColumn>           
   <ItemTemplate> 
        <asp:Image ID="myImages" ImageUrl='<%# DisplayImage(Container) %>'  runat="server" /> 
               
   </ItemTemplate> 
</telerik:GridTemplateColumn> 

cs:
public string DisplayImage(object c) 
    { 
        return "image /" + (DataBinder.Eval(c, "DataItem.image").ToString()) + ".gif"; 
 
    }   

Thanks
Princy.
Tags
Grid
Asked by
Tommy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or