Ed
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' '
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.RowDataBou nd
If e.Row.RowType = DataControlRowType.DataRowThen
Dim img As Image = DirectCast(e.Row.FindControl("imgTyp e"), Image)
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Full Code
Private Sub gvUploadedFiles_RowDataBou nd(sender As Object, e As GridViewRowEventArgs) Handles gvUploadedFiles.RowDataBou nd
If e.Row.RowType = DataControlRowType.DataRow Then
'If IsPostBack = True Then
Dim Filetype As Label = DirectCast(e.Row.FindContr ol("lbCont entType"), Label)
Dim ImType As System.Web.UI.WebControls. Image = CType(e.Row.FindControl("i mgType"), System.Web.UI.WebControls. Image)
If Filetype.Text = "application/vnd.ms-word" Then
ImType.ImageUrl = ("images/DeskIcons/word-ic on.png")
End If
End If
Private Sub gvUploadedFiles_RowDataBou
If e.Row.RowType = DataControlRowType.DataRow
'If IsPostBack = True Then
Dim Filetype As Label = DirectCast(e.Row.FindContr
Dim ImType As System.Web.UI.WebControls.
If Filetype.Text = "application/vnd.ms-word" Then
ImType.ImageUrl = ("images/DeskIcons/word-ic
End If
End If
ASKER
: Value of type 'System.Web.UI.Control' cannot be converted to 'System.Drawing.Image'.