Completed
Last Updated: 16 Mar 2016 13:22 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 29 Feb 2016 07:47
Category: GridView
Type: Bug Report
1
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
     Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)

     Dim obj As New ConditionalFormattingObject("MyCondition", ConditionTypes.Greater, "30", "", False)
     obj.CellBackColor = Color.SkyBlue
     obj.CellForeColor = Color.Red
     obj.TextAlignment = ContentAlignment.MiddleRight
     Me.RadGridView1.Columns("UnitPrice").ConditionalFormattingObjectList.Add(obj)
 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)
         myConnection.Open()
         Dim myDataTable As New DataTable
         Dim myAdapter As New OleDb.OleDbDataAdapter(myCommand)
         myAdapter.Fill(myDataTable)
         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
0 comments