Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lbl As Label = DirectCast(e.Row.FindControl("Label1"), Label)
Dim img As Image = DirectCast(e.Row.FindControl("Image1"), Image)
If lbl.Text = "5" Then
img.ImageUrl = "~/pics/rating_5.gif" 'Here I receive this error message: "Object reference not set to an instance of an object."
lbl.Text = "Very safe"
End If
End If
End Sub
When I comment out that line, I was able to edit the row but there's no image. I'm also not sure how to set the template field a read-only. Please help. Thanks!

New Topic/Question
Reply




MultiQuote





|