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

RadGrid with image column from other site

2 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Velissarios
Top achievements
Rank 1
Velissarios asked on 05 Sep 2011, 01:58 PM
Hello Dear Sir or Madam

I have a RadGrid on a site called: http://portal.recris.info
I have this site's admin site, under the URL: http://admin.recris.info

In the admin site, the users are manipulating the database, inserting, editing and deleting records.
In the RadGrid i mentioned earlier on portal.recris.info, I entered 4 image columns, in which I want to show the images, stored in the admin site.
For example in the database, there is a record with the Ship_photo1 field with the value: ~/images/accidents/Mega Bay - Ship-2-3.jpg, the Ship_Photo_2: ~/images/accidents/Jellyfish.jpg

I want these images to be seen in the portal.recris.info site.

I have the following code behind:

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
 
           If TypeOf e.Item Is GridDataItem Then
               Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
 
               Dim strImageUrl1 As String = item.GetDataKeyValue("Ship_Photo_1").ToString()
               DirectCast(item("Ship_Photo_1").Controls(16), Image).ImageUrl = "http://admin.recris.info/" + strImageUrl1.Replace("~/", "")
 
               Dim strImageUrl As String = item.GetDataKeyValue("Ship_Photo_2").ToString()
               DirectCast(item("Ship_Photo_2").Controls(17), Image).ImageUrl = "http://admin.recris.info/" + strImageUrl.Replace("~/", "")
 
               Dim strImageUrl2 As String = item.GetDataKeyValue("Accident_Photo_1").ToString()
               DirectCast(item("Accident_Photo_1").Controls(18), Image).ImageUrl = "http://admin.recris.info/" + strImageUrl2.Replace("~/", "")
 
               Dim strImageUrl3 As String = item.GetDataKeyValue("Accident_Photo_2").ToString()
               DirectCast(item("Accident_Photo_2").Controls(19), Image).ImageUrl = "http://admin.recris.info/" + strImageUrl3.Replace("~/", "")
 
           End If
 
       End Sub


and the following code at the .aspx file:

<telerik:GridImageColumn DataImageUrlFields="Ship_Photo_1"
                        HeaderText="Ship Photo 1" ImageAlign="Left" ImageHeight=""
                        ImageWidth="150px" UniqueName="Ship_Photo_1" AllowFiltering="False">
                    </telerik:GridImageColumn>
                    <telerik:GridImageColumn DataImageUrlFields="Ship_Photo_2"
                        HeaderText="Ship Photo 2" ImageAlign="Left" ImageHeight=""
                        ImageWidth="150px" UniqueName="Ship_Photo_2" AllowFiltering="False">
                    </telerik:GridImageColumn>
 
                    <telerik:GridImageColumn DataImageUrlFields="Accident_Photo_1"
                        HeaderText="Accident Photo 1" ImageAlign="Left" ImageHeight=""
                        ImageWidth="150px" UniqueName="Accident_Photo_1" AllowFiltering="False">
                    </telerik:GridImageColumn>
 
                    <telerik:GridImageColumn DataImageUrlFields="Accident_Photo_2"
                        HeaderText="Accident Photo 2" ImageAlign="Left" ImageHeight=""
                        ImageWidth="150px" UniqueName="Accident_Photo_2" AllowFiltering="False">
                    </telerik:GridImageColumn>

but it seems not working as expected.
At the portal.recris.info site, looking at the image properties, (from the browser's properties) I have the following:
http://portal.recris.info/images/ships/1162125%20Aiolos%201.jpg
but I need to be: http://admin.recris.info/images/ships/1162125%20Aiolos%201.jpg

Can you please take a look at the code, and tell me where I did the mistake?

Yours 
Velissarios Housos
vhousos@gmail.com


2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Sep 2011, 05:17 PM
Hello,

plz try with below  code snippet and let me know if any concern.

<telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <telerik:RadBinaryImage ID="RadBinaryImage" runat="server" ImageUrl='<%# "http://admin.recris.info/" + Eval("Ship_Photo_1").ToString().Replace("~/", "") %>' />
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>


Thanks,
Jayesh Goyani
0
Velissarios
Top achievements
Rank 1
answered on 06 Sep 2011, 11:22 AM
Dear Friend,

Thank you very much for your support
the snippset worked !!!!!!!

Thank you once more

Velissarios
vhousos@gmail.com
Tags
Grid
Asked by
Velissarios
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Velissarios
Top achievements
Rank 1
Share this question
or