locked
Extending GridView: new Behavior DefaultValue not working... RRS feed

  • Question

  • User-44394457 posted

    Using VS2005, VB code behind,

    I an expanding on the HotGridView control (http://msdn.microsoft.com/en-us/magazine/cc163612.aspx). During testing I noticed the "AutoGenerateCheckBoxColumn" behavior was returning true even if the user did not specify the a value in the markup but I expect it to return False if not value is supplied by the user - can anyone shed some light on why the AutoGenerateCheckBoxColumn is always true if not explicitly set to False in the markup? 


            <Category("Behavior")> _
            <Description("Whether a checkbox column is generated automatically at runtime")> _
            <DefaultValue(False)> _
            Public Property AutoGenerateCheckBoxColumn() As Boolean
                Get
                    Dim _obj As Object = ViewState("AutoGenerateCheckBoxColumn")
                    If _obj Is Nothing Then
                        Return False
                    Else
                        Return DirectCast(_obj, Boolean)
                    End If
                End Get
                Set(ByVal value As Boolean)
                    ViewState("AutoGenerateCheckBoxColumn") = value
                End Set
            End Property
    
            ''' <summary>
            ''' CreateColumns
            ''' </summary>
            ''' <param name="dataSource"></param>
            ''' <param name="useDataSource"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Protected Overrides Function CreateColumns(ByVal dataSource As PagedDataSource, ByVal useDataSource As Boolean) As ICollection
                ' Let the GridView create the default set of columns
                Dim _columnList As ICollection = MyBase.CreateColumns(dataSource, useDataSource)
                If Me.AutoGenerateCheckBoxColumn Then
                    ' Add a checkbox column if required
                    Dim _extendedColumnList As ArrayList = Me.AddCheckBoxColumn(_columnList)
                    Return _extendedColumnList
                Else
                    Return _columnList
                End If
    
            End Function



    Monday, March 1, 2010 1:49 PM

Answers

  • User-44394457 posted

    I figured this one out - it was simple - I had skinned my custom GridView - in my skin I had set the AutoGenerateCheckBoxColumn="true".

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 2, 2010 11:08 AM