Check if Eval(“VALUE”) is null
问题 Quite new to C# I need to cast a value to add minutes to a date but it can be null. Here's how I do : if(Eval("DUREE") != DBNull.Value) { var duration = Convert.ToInt32(Eval("DUREE")); var date = Convert.ToDateTime(Eval("DATE")); var dateAsString = Convert.ToString(date.AddMinutes(duration)); DataBinder.Eval(Container.DataItem, dateAsString, "{0:HH:mm}") } else { " - " } Here the error I get : DataBinding : 'System.Data.DataRowView' doesn't comport properties called : '17/04/2014 13:30:00'.