When the EnableConfigurationPanel is enabled for the PivotGrid and is being rendered without having data bound to it, the "System.NullReferenceException: Object reference not set to an instance of an object." exception will be thrown.
To replicate the problem, add the following PivotGrid declaration to the page without binding data to it:
<telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" EnableConfigurationPanel="true">
</telerik:RadPivotGrid>
Hi Daniel,
Thank you for reporting this problem.
We've looked into the source code and we found that when we're looping through the RadPivotGrid.ConfigurationPanel.RenderingControls collection is null if no data is bound to the Grid.
We will implement a condition that will first check and prevent the execution of the code when the Collection returns null.
Until the problem is fixed, you can do one of the following:
1. Make sure data is bound to the Grid prior to Rendering.
Protected Sub RadPivotGrid1_NeedDataSource(ByVal sender As Object, ByVal e As PivotGridNeedDataSourceEventArgs) Handles RadPivotGrid1.NeedDataSource
(TryCast(sender, RadPivotGrid)).DataSource = GetDataTable()
End If
End Sub
2. Keep the EnableConfigurationPanel set to false until binding, then enable it when needed.
On ButtonClick
Protected Sub RadButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
RadPivotGrid1.EnableConfigurationPanel = True 'Enable the Configuration Panel
RadPivotGrid1.DataSource = GetDataTable() 'Assign the DataSource
RadPivotGrid1.Rebind() 'Rebind the Grid for the changes to take effect
End Sub
In the NeedDataSource event:
Protected Sub RadPivotGrid1_NeedDataSource(ByVal sender As Object, ByVal e As PivotGridNeedDataSourceEventArgs) Handles RadPivotGrid1.NeedDataSource
'Implement your condition
If True Then
'Only enable the Configuration Panel If datasource is assigned
RadPivotGrid1.EnableConfigurationPanel = True
'Assign a datasource
(TryCast(sender, RadPivotGrid)).DataSource = GetDataTable()
End If
End Sub
Regards,
Attila Antal
Progress Telerik