4
Answers

Handling null values in Eval()

Marius Vasile

Marius Vasile

1y
573
1

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)