2

I have an image control on an ASP.NET web form that gets the ImageUrl from one of the BoundColumns of a DetailView control on the same page. When the page loads it works fine and the image appears, but when I click edit on one of the fields in the DetailView and the control goes into "edit mode" the image does not display. The control is still there but the image is not. I checked to see and the ImageUrl at that point is still correct. I have attached the code.

Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound
    Image1.ImageUrl = ""
    If Not String.IsNullOrEmpty(DetailsView1.Rows(14).Cells(1).Text) Then
        Image1.ImageUrl = "~/App_Themes/Light/Images/" & DetailsView1.Rows(14).Cells(1).Text
    End If
End Sub

Protected Sub DetailsView1_ModeChanged(sender As Object, e As System.EventArgs) Handles DetailsView1.ModeChanged
    If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
        DropDownList1.Visible = False
        Image1.Visible = False
    ElseIf DetailsView1.CurrentMode = DetailsViewMode.Edit Or DetailsView1.CurrentMode = DetailsViewMode.ReadOnly Then
        DropDownList1.Visible = True
        Image1.Visible = True
    End If
End Sub
4

0 回答 0