我在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