Link to home
Start Free TrialLog in
Avatar of Ed
EdFlag for United Kingdom of Great Britain and Northern Ireland

asked on

FInd Image Control Gridview

How do I find an image control in a gidview so I can chnage the image source on rowdatabound.

I've tried like this which I thought should work but I keep getting

'Value type 'Control' cannot be converted to ' Image'   '


   Private Sub gvUploadedFiles_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvUploadedFiles.RowDataBound

       If e.Row.RowType = DataControlRowType.DataRow Then
 
  Dim img As Image = DirectCast(e.Row.FindControl("imgType"), Image)


        End If
Avatar of Ed
Ed
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

The error is

: Value of type 'System.Web.UI.Control' cannot be converted to 'System.Drawing.Image'.
ASKER CERTIFIED SOLUTION
Avatar of Ed
Ed
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ed

ASKER

Full Code

    Private Sub gvUploadedFiles_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvUploadedFiles.RowDataBound


        If e.Row.RowType = DataControlRowType.DataRow Then
            'If IsPostBack = True Then

            Dim Filetype As Label = DirectCast(e.Row.FindControl("lbContentType"), Label)



            Dim ImType As System.Web.UI.WebControls.Image = CType(e.Row.FindControl("imgType"), System.Web.UI.WebControls.Image)



            If Filetype.Text = "application/vnd.ms-word" Then
                ImType.ImageUrl = ("images/DeskIcons/word-icon.png")



            End If

        End If