jeudi 4 juin 2015

Ironspeed: initializing checkbox value on edit page

On my edit page I have the checbkox control referring to the nchar(5) (yes, it should be bit...) field called "OKToPack". Since this page is editing existing record, I'd like for the checkbox control to represent currently existing values - so I'd like it to be checked when the row I am editing has OKToPack="True". Unfortunately its not that easy:

I've set "Checked value" property to "True" (and "Unchecked" to "False", so ISD knows what to write down when the I check/uncheck the box), and the Set() property has code

If Me.DataSource IsNot Nothing AndAlso Me.DataSource.OKToPackSpecified Then

            ' If the OKToPack is non-NULL, then format the value.
            ' The Format method will use the Display Format
            If Me.DataSource.OKToPack.ToString() = "True" Then

                Me.OKToPack.Checked = True
            Else
                Me.OKToPack.Checked = False
            End If

        Else

            ' OKToPack is NULL in the database, so use the Default Value.  
            ' Default Value could also be NULL.
            If Not Me.DataSource.IsCreated Then
                Me.OKToPack.Checked = Exports1Table.OKToPack.ParseValue(Exports1Table.OKToPack.DefaultValue).ToBoolean()
            End If

        End If

    End Sub

Unfortunately even with that, when I'm editing row with OKToPack="True" the checkbox is initially unchecked. Oh, the "Initialuze when editing =OKToPack"

Aucun commentaire:

Enregistrer un commentaire