This is a migrated thread and some comments may be shown as answers.

CheckBox within a Radgrid Template Column?

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shuja
Top achievements
Rank 1
Shuja asked on 17 May 2011, 06:31 PM
Hi,

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
    Else
        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
        Get
            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
            Else
                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 http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx) 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?

Regards,

Shuja

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 20 May 2011, 01:53 PM
Hello Shuja,

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

Best wishes,
Mira
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.

Tags
Grid
Asked by
Shuja
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or