locked
Convert DataBinder.Eval RRS feed

  • Question

  • User-604637336 posted

    Hello, 

     If (DataBinder.Eval(e.Item.DataItem, "value") <> DBNull.Value) Then
    
          some conversion        
    
      End If

    Operator '<>' is not defined for types 'Object' and 'System.DBNull' 

    Could you give me any solution with this ?

    Thanks

    Thursday, May 23, 2013 4:00 PM

Answers

  • User-183374066 posted

    I am not a vb guy but i suggest you if it isn't working than you can compare like

    If Not String.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(e.Item.DataItem, "value"))) Then
    
    End If

    Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2013 4:15 PM
  • User1992938117 posted

    You can use IIf for better performace, See:

     IIf(IsDBNull(DataBinder.Eval(e.Item.DataItem, "value")) OrElse _
                String.IsNullOrEmpty(DataBinder.Eval(e.Item.DataItem, "value")), "", "some(Conversion)")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2013 4:21 PM

All replies

  • User-183374066 posted

    I am not a vb guy but i suggest you if it isn't working than you can compare like

    If Not String.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(e.Item.DataItem, "value"))) Then
    
    End If

    Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2013 4:15 PM
  • User-604637336 posted

    Cool its working, thanks for fast answer.

    Thursday, May 23, 2013 4:20 PM
  • User1992938117 posted

    You can use IIf for better performace, See:

     IIf(IsDBNull(DataBinder.Eval(e.Item.DataItem, "value")) OrElse _
                String.IsNullOrEmpty(DataBinder.Eval(e.Item.DataItem, "value")), "", "some(Conversion)")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2013 4:21 PM