ASP.Net load items – an efficient way to check for isDBNull to populate a control

This was the original way to check for a database field being null before putting it into a label:

if not isDBNull(dr(“FieldName”)) then

Me.label1.text = dr(“FieldName”).ToString


Me.label1.text = “”

end if

however there is a much better and more efficient way….

Me.label1.text = dr.field(of String)(“FieldName”)


Leave a Reply