CheckBox within a Radgrid Template Column?

2 posts, 0 answers
  1. Shuja
    Shuja avatar
    30 posts
    Member since:
    Mar 2011

    Posted 17 May 2011 Link to this post


    I am trying to use a data bound Checkbox in a RadGrid Template Column but have come across several problems.
    Firstly, i was trying to use the asp checkbox control. This works for displaying the existing data from my database but i get a DBnull error when i try to insert a new record.
    So i tried to resolve this error by trying to capture the DBNull with a CheckNull function:
    Public Function CheckNull(ByVal val As Object) As Boolean
        If val.GetType Is DBNull.Value.GetType Then
            Return False
            Return Convert.ToBoolean(val)
        End If
    End Function

    but this didn't work. I then tried a custom CheckBox which overrides the DBNull error but this didn't fix the problem either

    Public Class CustomCheckBox
        Inherits Web.UI.WebControls.CheckBox
        Public Property CheckedOverride() As Object
                Return MyBase.Checked
            End Get
            Set(ByVal value As Object)
                If IsDBNull(value) Then
                    MyBase.Checked = False
                ElseIf value.GetType() = GetType(Boolean) Then
                    MyBase.Checked = value
                    MyBase.Checked = False
                End If
            End Set
        End Property
    End Class

    I then searched the Telerik forums for a solution & came across the telerik:GridCheckBoxColumn (from this site BUT i do not have this available to me! When i enter this control i get an error saying it does not exist.

    Is this an old control item which has been phased out or should it still be available to me on the latest version of Telerik controls?

    if it isn't available then can you provide an alternative solution for the databound checkbox which is causing a DBnull conversion error?


  2. Mira
    Mira avatar
    1124 posts

    Posted 20 May 2011 Link to this post

    Hello Shuja,

    Please try setting the RetrieveNullAsDBNull property of the MasterTableView to true and let me know whether it helps.

    Best wishes,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top