当将同一表单上的detailview放入editmode时,asp.net webform上的图像消失

时间:2013-08-29 12:53:49

标签: asp.net detailsview

我在ASP.NET网络表单上有一个图像控件,它从同一页面上ImageUrl控件的BoundColumn之一获取DetailView。当页面加载时它工作正常并且图像出现,但是当我在DetailView中的某个字段上单击编辑并且控件进入“编辑模式”时,图像不会显示。控件仍在那里,但图像不是。我查看了,那时ImageUrl仍然是正确的。我附上了代码。

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

0 个答案:

没有答案