I have an issue adding a user control to the RadPanelBar (ajax) Q3 2008 version.
My markup is as follows:
<div style="margin-left: 20px;">
<telerik:RadPanelBar ID="ParameterPanels" ExpandMode="MultipleExpandedItems" runat="server" Skin="Web20" Width="95%">
<Items>
<telerik:RadPanelItem runat="server">
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>
</div>
In the code behind, I have the following code
foreach(ParameterControl aParameterControl in parameterControls)
{
// Load the parameter controls dynamically as long as we don't
// find a static value or data field parameter control
if(aParameterControl.ParameterControlID != 2 &&
aParameterControl.ParameterControlID != 29)
{
RadPanelItem panelItem = new RadPanelItem(aParameterControl.ParameterControlDescription);
Control c = Page.LoadControl(aParameterControl.ControlPath);
panelItem.Controls.Add(c);
ParameterPanels.Items.Add(panelItem);
}
}
}
and I end up with the following stacktrace
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
|
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] |
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
further info:
Interestingly, if I change my markup to look like this, I don't get the error (I removed the first radPanelItem in the radPanelBar items collection)
<div style="margin-left: 20px;">
<telerik:RadPanelBar ID="ParameterPanels" ExpandMode="MultipleExpandedItems" runat="server" Skin="Web20" Width="95%">
</telerik:RadPanelBar>
</div>
I would have thought that the control wouldn't be sensitive to an empty RadPanelItem but it obviously is. I would suggest that a null check is placed in the source for the next release around if that is the root of the issue.
Telerik.Web.UI.ControlItem.get_Index() +31
Telerik.Web.UI.RadPanelItem.get_IsFirstVisibleItem() +27
Thanks,
Sabry