Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

namio

Colocar uma classe em viewstate

Recommended Posts

Criei uma classe ENContrato e, ao salvá-la em viewstate, obtenho o seguinte erro: Tipo 'Scc.ENContrato' deve ser marcado como Serializable ou ter um TypeConverter diferente de ReferenceConverter para ser colocado em ViewState. A declaração da classe encontra-se da seguinte maneira: <Serializable()> Public Class ENContrato .... end Class Como devo proceder para poder colocar esta classe e demais classes derivadas dela em viewstate?

 

Para maior clareza, segue o código da classe:

 

<SerializableAttribute()> Public Class ENContrato    Protected vtg_DthAssinatura As Date    Protected vtg_DthCarencia As Date    Protected vtg_DthInicio As Date    Protected vtg_DthOs As Date    Protected vtg_DthPublicacaoDo As Date    Protected vtg_DthRescisao As Date    Protected vtg_DthTerminoOriginal As Date    Protected vtg_DthTransmissao As Date    Protected vdg_VlrTaxaJuros As Double    Protected vdg_VlrTotalContrato As Double    Protected vdg_vlrTotalMoeda As Double    Protected vig_IsnContrato As Integer    Protected vig_IsnContratoClassificacao As Integer    Protected vig_IsnEntidadeResponsavel As Integer    Protected vsg_FlgAprovacaoConvenio As String    Protected vsg_FlgJurosCarencia As String    Protected vsg_FlgMestre As String    Protected vsg_FlgSubvencao As String    Protected vsg_FlgTipoContrato As String    Protected vsg_FlgTipoFinanciamento As String    Protected vsg_FlgUniaoEstado As String    Protected vsg_DscJustificativa As String    Protected vsg_DscObjeto As String    Protected vsg_DscObservacao As String    Protected vsg_DscAmortizacao As String    Protected vsg_DscFundamentacao As String    Protected vsg_DscMoeda As String    Protected vsg_NumContrato As String    Protected vog_Licitacao As en_Licitacao    Protected vog_Alteracao As en_UsuarioIo    Protected vog_Inclusao As en_UsuarioIo    Protected vog_Exclusao As en_UsuarioIo    Public Property DataAssinatura() As Date      Get        Return vtg_DthAssinatura      End Get      Set(ByVal Value As Date)        vtg_DthAssinatura = Value      End Set    End Property    Public Property DataCarencia() As Date      Get        Return vtg_DthCarencia      End Get      Set(ByVal Value As Date)        vtg_DthCarencia = Value      End Set    End Property    Public Property DataInicio() As Date      Get        Return vtg_DthInicio      End Get      Set(ByVal Value As Date)        vtg_DthInicio = Value      End Set    End Property    Public Property DataOs() As Date      Get        Return vtg_DthOs      End Get      Set(ByVal Value As Date)        vtg_DthOs = Value      End Set    End Property    Public Property DataPublicacao() As Date      Get        Return vtg_DthPublicacaoDo      End Get      Set(ByVal Value As Date)        vtg_DthPublicacaoDo = Value      End Set    End Property    Public Property DataRescisao() As Date      Get        Return vtg_DthRescisao      End Get      Set(ByVal Value As Date)        vtg_DthRescisao = Value      End Set    End Property    Public Property DataTerminoOriginal() As Date      Get        Return vtg_DthTerminoOriginal      End Get      Set(ByVal Value As Date)        vtg_DthTerminoOriginal = Value      End Set    End Property    Public Property DataTransmissao() As Date      Get        Return vtg_DthTransmissao      End Get      Set(ByVal Value As Date)        vtg_DthTransmissao = Value      End Set    End Property    Public Property TaxaDeJuros() As Double      Get        Return IIf(vdg_VlrTaxaJuros = Nothing, 0, vdg_VlrTaxaJuros)      End Get      Set(ByVal Value As Double)        vdg_VlrTaxaJuros = IIf(Value = 0, Nothing, Value)      End Set    End Property    Public Property ValorTotalContrato() As Double      Get        Return IIf(vdg_VlrTotalContrato = Nothing, 0, vdg_VlrTotalContrato)      End Get      Set(ByVal Value As Double)        vdg_VlrTotalContrato = IIf(Value = 0, Nothing, Value)      End Set    End Property    Public Property ValorTotalMoeda() As Double      Get        Return IIf(vdg_vlrTotalMoeda = Nothing, 0, vdg_vlrTotalMoeda)      End Get      Set(ByVal Value As Double)        vdg_vlrTotalMoeda = IIf(Value = 0, Nothing, Value)      End Set    End Property    Public Property Isn() As Integer      Get        Return IIf(vig_IsnContrato = Nothing, -1, vig_IsnContrato)      End Get      Set(ByVal Value As Integer)        If Value = -1 OrElse Value = 0 Then          vig_IsnContrato = Nothing        Else          vig_IsnContrato = Value        End If      End Set    End Property    Public Property IsnClassificacao() As Integer      Get        Return IIf(vig_IsnContratoClassificacao = Nothing, -1, vig_IsnContratoClassificacao)      End Get      Set(ByVal Value As Integer)        If Value = -1 OrElse Value = 0 Then          vig_IsnContratoClassificacao = Nothing        Else          vig_IsnContratoClassificacao = Value        End If      End Set    End Property    Public Property IsnEntidadeResponsavel() As Integer      Get        Return IIf(vig_IsnEntidadeResponsavel = Nothing, -1, vig_IsnEntidadeResponsavel)      End Get      Set(ByVal Value As Integer)        If Value = -1 OrElse Value = 0 Then          vig_IsnEntidadeResponsavel = Nothing        Else          vig_IsnEntidadeResponsavel = Value        End If      End Set    End Property    Public Property UsuarioAlteracao() As en_UsuarioIo      Get        Return vog_Alteracao      End Get      Set(ByVal Value As en_UsuarioIo)        vog_Alteracao = Value      End Set    End Property    Public Property UsuarioExclusao() As en_UsuarioIo      Get        Return vog_Exclusao      End Get      Set(ByVal Value As en_UsuarioIo)        vog_Exclusao = Value      End Set    End Property    Public Property UsuarioInclusao() As en_UsuarioIo      Get        Return vog_Inclusao      End Get      Set(ByVal Value As en_UsuarioIo)        vog_Inclusao = Value      End Set    End Property    Public Property FlagConvenioAprovado() As String      Get        Return IIf(vsg_FlgAprovacaoConvenio = Nothing, String.Empty, vsg_FlgAprovacaoConvenio)      End Get      Set(ByVal Value As String)        If Not (Value Is Nothing) Then          vsg_FlgAprovacaoConvenio = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property FlagJurosCarencia() As String      Get        Return IIf(vsg_FlgJurosCarencia = Nothing, String.Empty, vsg_FlgJurosCarencia)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_FlgJurosCarencia = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property FlagMestre() As String      Get        Return IIf(vsg_FlgMestre = Nothing, String.Empty, vsg_FlgMestre)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_FlgMestre = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property FlagSubvencao() As String      Get        Return IIf(vsg_FlgSubvencao = Nothing, String.Empty, vsg_FlgSubvencao)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_FlgSubvencao = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property Tipo() As String    Get      Return IIf(vsg_FlgTipoContrato = Nothing, String.Empty, vsg_FlgTipoContrato)    End Get    Set(ByVal Value As String)      If Not Value Is Nothing Then        vsg_FlgTipoContrato = IIf(Value = String.Empty, Nothing, Value.Trim)      End If    End Set    End Property    Public Property FlagFinanciamento() As String      Get        Return IIf(vsg_FlgTipoFinanciamento = Nothing, String.Empty, vsg_FlgTipoFinanciamento)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_FlgTipoFinanciamento = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property FlagUniaoEstado() As String      Get        Return IIf(vsg_FlgUniaoEstado = Nothing, String.Empty, vsg_FlgUniaoEstado)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_FlgUniaoEstado = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property Justificativa() As String      Get        Return IIf(vsg_DscJustificativa = Nothing, String.Empty, vsg_DscJustificativa)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_DscJustificativa = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property Objeto() As String    Get      Return IIf(vsg_DscObjeto = Nothing, String.Empty, vsg_DscObjeto)    End Get    Set(ByVal Value As String)      If Not Value Is Nothing Then        vsg_DscObjeto = IIf(Value = String.Empty, Nothing, Value.Trim)      End If    End Set    End Property    Public Property Observacao() As String    Get      Return IIf(vsg_DscObservacao = Nothing, String.Empty, vsg_DscObservacao)    End Get    Set(ByVal Value As String)      If Not Value Is Nothing Then        vsg_DscObservacao = IIf(Value = String.Empty, Nothing, Value.Trim)      End If    End Set    End Property    Public Property Amortizacao() As String      Get        Return IIf(vsg_DscAmortizacao = Nothing, String.Empty, vsg_DscAmortizacao)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_DscAmortizacao = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property Fundamentacao() As String      Get        Return IIf(vsg_DscFundamentacao = Nothing, String.Empty, vsg_DscFundamentacao)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_DscFundamentacao = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property Moeda() As String    Get      Return IIf(vsg_DscMoeda = Nothing, String.Empty, vsg_DscMoeda)    End Get    Set(ByVal Value As String)      If Not Value Is Nothing Then        vsg_DscMoeda = IIf(Value = String.Empty, Nothing, Value.Trim)      End If    End Set    End Property    Public Property Numero() As String      Get        Return IIf(vsg_NumContrato = Nothing, String.Empty, vsg_NumContrato)      End Get      Set(ByVal Value As String)        If Not Value Is Nothing Then          vsg_NumContrato = IIf(Value = String.Empty, Nothing, Value.Trim)        End If      End Set    End Property    Public Property Licitacao() As en_Licitacao      Get        Return vog_Licitacao      End Get      Set(ByVal Value As en_Licitacao)        vog_Licitacao = Value      End Set    End Property    Public Property Alteracao() As en_UsuarioIo    Get      Return vog_Alteracao    End Get    Set(ByVal Value As en_UsuarioIo)      vog_Alteracao = Value    End Set    End Property    Public Property Inclusao() As en_UsuarioIo      Get        Return vog_Inclusao      End Get      Set(ByVal Value As en_UsuarioIo)        vog_Inclusao = Value      End Set    End Property    Public Property Exclusao() As en_UsuarioIo      Get        Return vog_Exclusao      End Get      Set(ByVal Value As en_UsuarioIo)        vog_Exclusao = Value      End Set    End Property    Public Sub New() 'Instancia uma classe com valores nulos      vog_Licitacao = New en_Licitacao      vog_Alteracao = New en_UsuarioIo      vog_Inclusao = New en_UsuarioIo      vog_Exclusao = New en_UsuarioIo      Clear()      vig_IsnContrato = Nothing    End Sub    Public Sub New(ByVal isn As Integer)      Me.New()      vig_IsnContrato = isn    End Sub    Public Overridable Sub Clear() 'Limpa o conteúdo das variáveis locais      vtg_DthAssinatura = Nothing      vtg_DthCarencia = Nothing      vtg_DthInicio = Nothing      vtg_DthOs = Nothing      vtg_DthPublicacaoDo = Nothing      vtg_DthRescisao = Nothing      vtg_DthTerminoOriginal = Nothing      vtg_DthTransmissao = Nothing      vdg_VlrTaxaJuros = Nothing      vdg_VlrTotalContrato = Nothing      vdg_vlrTotalMoeda = Nothing      vig_IsnContratoClassificacao = Nothing      vig_IsnEntidadeResponsavel = Nothing      vsg_FlgAprovacaoConvenio = Nothing      vsg_FlgJurosCarencia = Nothing      vsg_FlgMestre = Nothing      vsg_FlgSubvencao = Nothing      vsg_FlgTipoContrato = Nothing      vsg_FlgTipoFinanciamento = Nothing      vsg_FlgUniaoEstado = Nothing      vsg_DscJustificativa = Nothing      vsg_DscObjeto = Nothing      vsg_DscObservacao = Nothing      vsg_DscAmortizacao = Nothing      vsg_DscFundamentacao = Nothing      vsg_DscMoeda = Nothing      vsg_NumContrato = Nothing      vog_Licitacao.Clear()      vog_Alteracao.Clear()      vog_Inclusao.Clear()      vog_Exclusao.Clear()    End Sub  End Class

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.