Marius Vasile

Marius Vasile

  • 552
  • 1.9k
  • 145.8k

Handling null values in Eval()

Nov 30 2023 11:35 AM

I have a Datalist which depending on condition can be populated from 3 queries. The problem I have is that one query generates one additional field which the other two doesn't and when I run the query I have the following error

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MediuMunca'.

I tried to handle this with

Text='<%#(Eval("MediuMunca") == null ? "-" : Eval("MediuMunca"))%>'

Text='<%#Eval("MediuMunca") == DBNull.Value ? "-" : Eval("MediuMunca")%>'

but is not working. What am I doing wrong?


Answers (4)