Public Class ClassControlValuesConverter
    Public Shared Function ToBooleanOrDefault(value As Object, Optional defaultValue As Boolean = False)
        Try
            If IsDBNull(value) OrElse value = "" Then
                Return defaultValue
            Else
                Return Convert.ToBoolean(value)
            End If
        Catch ex As Exception
            Return defaultValue
        End Try
    End Function

    Public Shared Function ToStringOrDefault(value As Object, Optional defaultValue As String = "")
        Try
            If IsDBNull(value) OrElse String.IsNullOrEmpty(value) Then
                Return defaultValue
            Else
                Return Convert.ToString(value)
            End If
        Catch ex As Exception
            Return defaultValue
        End Try
    End Function


    Public Shared Function ToIntOrDefault(value As Object, Optional defaultValue As Integer = 0)
        Try
            If IsDBNull(value) Then
                Return defaultValue
            Else
                Return Convert.ToInt16(value)
            End If
        Catch ex As Exception
            Return defaultValue
        End Try
    End Function
End Class
