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

RadGrid, image fails to show

3 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 12 May 2012, 09:09 PM
I'm trying to load one image for all rows in my radgrid, however, all i'm able to get to appear is the alternate text.  The code below is what I'm using:

                        <telerik:GridImageColumn DataType="System.String" DataImageUrlFields="ValletImage"
                            DataImageUrlFormatString="images/{0}.jpeg" AlternateText="Customer image" DataAlternateTextField="ContactName"
                            ImageAlign="Middle" ImageHeight="110px" ImageWidth="90px" HeaderText="Vallet"
                            FooterText="Vallet" ImageUrl="~/vallet.aspx?={0}" />

My datarow produces ValletImages = "mypicture" for each picture.  In this case all my rows appear as "smallpic", i'm expecting it to look for images/mypicture.jpeg but it refuses to load.

Do I have it wrong or is there something I need to change?  Also, i am trying to have a specific URL per picture.

Thanks

3 Answers, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 1
answered on 12 May 2012, 09:37 PM
I figured out how to get the image to appear on the GridImageColumn, but how do I use that image as a button using GridButtonColumn?  I tried the same format and it just makes the DataTextFormatString appear.
I changed this code to this:

<telerik:GridButtonColumn FooterText="ImageButtonColumn<br/>footer" DataTextFormatString="Select ~/images/{0}"
                        ButtonType="ImageButton" UniqueName="valletimagebutton" HeaderText="ImageButton<br/>Column" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                        CommandName="Select" DataTextField="ValletImage" ImageUrl="~/images/{0}">

and in the ImageButton Column it displays select ~/images/valletcarlot.jpg which is the correct path
0
Joshua
Top achievements
Rank 1
answered on 12 May 2012, 10:18 PM
I changed the code again:
<telerik:GridButtonColumn FooterText="ImageButtonColumn<br/>footer" DataTextFormatString="/images/{0}"
                        ButtonType="ImageButton" UniqueName="valletimagebutton" HeaderText="ImageButton<br/>Column" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                        CommandName="Select" DataTextField="ValletImage" ImageUrl="images/{0}">

the changed the code and it produced this as the HTML source code
src="~/images/{0}" alt="/images/valletcarlot.jpg"

so I was curious was to why the {0} didn't get translated.  I added DataType="System.String"
however, this left the {0} still in tact, so I had to hard code the image in ImageURL to ImageUrl="images/valletcarlot.jpg"> and the image displays.


is this intended?  Or maybe a bug?  It is also quite possible I dont understand.  Thanks for the help, I would really like to keep this as a dynamic selection.

Thanks!!!
0
Richard
Top achievements
Rank 1
answered on 16 May 2012, 05:23 PM
Joshua,

I'm not exactly clear on what you're trying to accomplish here, but I wanted to direct you to this thread that I was involved in recently, as it may provide some insights into solving your requirements. It's a somewhat similar issue.

GridHyperLinkColumn with dynamic image

Hope this helps!
Tags
Grid
Asked by
Joshua
Top achievements
Rank 1
Answers by
Joshua
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or