Last Updated: 16 Mar 2016 13:22 by ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 29 Feb 2016 07:47
Category: GridView
Type: Bug Report
FIX. RadGridView - DataException is thrown when resetting the DataSource and a ConditionalFormattingObject is available
To reproduce:

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
     Me.RadGridView1.DataSource = Me.ProductsBindingSource

     Dim obj As New ConditionalFormattingObject("MyCondition", ConditionTypes.Greater, "30", "", False)
     obj.CellBackColor = Color.SkyBlue
     obj.CellForeColor = Color.Red
     obj.TextAlignment = ContentAlignment.MiddleRight
 End Sub

 Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
     Dim mySQL As String = "SELECT * FROM Products where ProductName = 'Chaii'"
     Dim myTable As DataTable = getDataInTable(mySQL, My.Settings.NwindConnectionString)
     Me.RadGridView1.DataSource = myTable
 End Sub
 Public Shared Function getDataInTable(mySQLorTable As String, myConnectionString As String, Optional myTimeout As Integer = 30) As DataTable
     Using myConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Nwind.mdb")
         Dim myCommand As New OleDb.OleDbCommand(mySQLorTable, myConnection)
         Dim myDataTable As New DataTable
         Dim myAdapter As New OleDb.OleDbDataAdapter(myCommand)
         Return myDataTable
     End Using
 End Function

When you click the button, the grid is refilled with the query result which does not contain any rows. As a result, a DataException is thrown for each column: "There is no property descriptor corresponding to property name: 'ColumnName'" .  

Workaround: clear the conditional formatting objects, reset the DataSource and add the conditional formatting objects back
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)