image on a datagrid

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hey all,
have a dategrd and am storing a url to an image in it. I
have no idea how to show the actual image. Can anyone give
me a hand or point me towards an example they know of. I
have searched the web and haven't found anything that is
of much use. Cheers and have a good one,
Tom
 
figured it out myself if anyone is interested:

Private Sub dgName_ItemDataBound(ByVal sender As
Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgName.ItemDataBound
'will be used to set the value of the image in the
datagrid
Dim imgTest As New System.Web.UI.WebControls.Image
()

If e.Item.ItemType = ListItemType.Item _
Or e.Item.ItemType = ListItemType.AlternatingItem
Then
'we have hard coded the text "No image
available" earlier on. And look for it here.
'if that is the text then out put it, if not,
out put the picture
imgTest.ImageUrl = e.Item.Cells(5).Text
If imgTest.ImageUrl = "No image available" Then
e.Item.Cells(5).Text() = imgTest.ImageUrl
Else
e.Item.Cells(5).Controls.Add(imgTest)
End If
End If
End Sub

thanks anyway,
tom
 
Back
Top