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

Error during ValueChanged for Checkbox

2 Answers 107 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stephane
Top achievements
Rank 1
Stephane asked on 23 Nov 2010, 03:25 PM

Hi,
I try to use the RadDataGridWiew to binding my collection of Object.

I define 5 columns wich one is a checkboxcolumn.

But when i click on the checkboxcell, the datagridwiew throw an exception "Data Exception".
the error indicates that it's impossible to convert the value "Off" to boolean type.

???

Best regards.

2 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 23 Nov 2010, 03:39 PM
Hello,

In your object collection, you need to return a boolean for the checkbox column. Please try the following simple code exmaple (just a grid on a form) which should help to show how to add a checkbox column.

Imports Telerik.WinControls.UI
Imports Telerik.WinControls
  
Public Class Form1
  
    Public Sub New()
        InitializeComponent()
    End Sub
  
  
    Private Sub Form1_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
  
        Dim people As New List(Of Person)
        people.Add(New Person(1, "Richard", False))
        people.Add(New Person(1, "Bob", False))
        people.Add(New Person(1, "Peter", True))
        people.Add(New Person(1, "Stew", Nothing))
  
        Me.RadGridView1.AutoGenerateColumns = False
  
        Me.RadGridView1.Columns.Add(New GridViewDecimalColumn("Id", "Id"))
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("Name", "Name"))
        Me.RadGridView1.Columns.Add(New GridViewCheckBoxColumn("HasBeard", "HasBeard"))
  
        Me.RadGridView1.DataSource = people
  
    End Sub
  
  
End Class
  
Public Class Person
    Private m_Id As Integer
    Private m_Name As String
    Private m_HasBeard As Boolean
  
    Public Sub New(ByVal id As Integer, ByVal name As String, ByVal hasBeard As Boolean)
        m_Name = name
        m_Id = id
        m_HasBeard = hasBeard
    End Sub
  
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set(ByVal value As String)
            m_Name = value
        End Set
    End Property
  
    Public Property Id() As Integer
        Get
            Return m_Id
        End Get
        Set(ByVal value As Integer)
            m_Id = value
        End Set
    End Property
  
    Public Property HasBeard() As Boolean
        Get
            Return m_HasBeard
        End Get
        Set(ByVal value As Boolean)
            m_HasBeard = value
        End Set
    End Property
  
End Class


If you need further help, please let me know.
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 23 Nov 2010, 03:57 PM
Hello,

Here is also a help article on GridViewCheckBoxColumn

Let me know if you need further help
Richard
Tags
GridView
Asked by
Stephane
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Share this question
or