Hi,
I have a grid view , which has paging enabled.
When i try to change the page size , i am getting the below error.
" Specified argument was out of the range of valid values.
Parameter name: ItemHierarchicalIndex
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." Please let me know if there is a fix for this.
Thanks,
Raghav.
3 Answers, 1 is accepted
Could you please share your page markup as well as the related code behind. Thus we will be able to further inveterate on your code and o our best to isolate the root cause of the error.
Kind regards,
Maria Ilieva
the Telerik team
PFB the grid mark up whihc is causing this issue.
<telerik:RadGrid ID="rdTrialBalance" Width="100%" BorderStyle="None"
AutoGenerateColumns="False" OnItemDataBound="rdTrialBalance_ItemDataBound"
OnNeedDataSource="rdTrialBalance_NeedDataSource" runat="server"
OnUpdateCommand="rdTrialBalance_UpdateCommand" OnCancelCommand="rdTrialBalance_CancelCommand"
AllowPaging="True" PageSize="50"
OnPageIndexChanged="rdTrialBalance_PageIndexChanged" CellSpacing="0"
GridLines="None" PagerStyle-AlwaysVisible="true" ShowFooter="true" >
<MasterTableView DataKeyNames="AdjustmentID" AllowPaging="true" PagerStyle-AlwaysVisible="true" PageSize="50" EnableViewState="true"
>
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
Visible="True">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
Visible="True">
</ExpandCollapseColumn>
<Columns>
<telerik:GridTemplateColumn HeaderStyle-Width="25px" ItemStyle-Width="25px"
UniqueName="Phase">
<HeaderTemplate>
<asp:CheckBox ID="chkSelectAll" runat="server"
onclick="javascript:SelectAllCheckBoxes(this)" Text="" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<HeaderStyle Width="25px" />
<ItemStyle Width="25px" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn AllowFiltering="false" DataField="FieldName"
FooterStyle-Font-Bold="true" FooterStyle-HorizontalAlign="Right"
FooterText="Total" HeaderStyle-Width="85px" HeaderStyle-Wrap="true"
HeaderText="Line" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="85px"
ReadOnly="true" ShowFilterIcon="false" SortExpression="FieldName"
UniqueName="FieldName" Visible="true">
<FooterStyle Font-Bold="True" HorizontalAlign="Right" />
<HeaderStyle Width="85px" Wrap="True" />
<ItemStyle HorizontalAlign="Left" Width="85px" />
</telerik:GridBoundColumn>
<%
--<telerik:GridBoundColumn DataField="PerBook" DataFormatString="{0:###,##0}" ItemStyle-Width="7%" ReadOnly="true" UniqueName="PerBook" SortExpression="PerBook"
Visible="true" HeaderText="Per Book" HeaderStyle-Width="7%" HeaderStyle-Wrap="true" AllowFiltering="false" ShowFilterIcon="false"
ItemStyle-HorizontalAlign="right" FooterText="Total" FooterStyle-HorizontalAlign="Right" FooterStyle-Font-Bold="true" />--
%>
<telerik:GridTemplateColumn DataField="PerBook" EditFormColumnIndex="1"
HeaderStyle-Width="65px" HeaderStyle-Wrap="true" HeaderText="Per Book"
ItemStyle-HorizontalAlign="right" ItemStyle-Width="65px" UniqueName="PerBook">
<ItemTemplate>
<asp:Label ID="lblPerBook" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "PerBook", "{0:###,##0}")%>'
Visible="false"></asp:Label>
<telerik:RadNumericTextBox ID="txtPerBook" runat="server"
EnabledStyle-HorizontalAlign="Right" ReadOnly="false"
Value='<%# DataBinder.Eval(Container.DataItem, "PerBook")%>' Width="50">
<NumberFormat DecimalDigits="0" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblPerBookTotal" runat="server" Visible="true"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle HorizontalAlign="Right" Width="65px" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="BookAdjustments" EditFormColumnIndex="1"
HeaderStyle-Width="65px" HeaderStyle-Wrap="true"
HeaderText="Book<br/>Adjustments" ItemStyle-HorizontalAlign="right"
ItemStyle-Width="65px" UniqueName="BookAdjustments">
<ItemTemplate>
<telerik:RadNumericTextBox ID="txtBookAdjustments" runat="server"
EnabledStyle-HorizontalAlign="Right" ReadOnly="false"
Value='<%# DataBinder.Eval(Container.DataItem, "BookAdjustments")%>' Width="50">
<NumberFormat DecimalDigits="0" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblBookAdjustments" runat="server" Visible="true"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle HorizontalAlign="Right" Width="65px" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="BookReclass" EditFormColumnIndex="2"
HeaderStyle-Width="65px" HeaderStyle-Wrap="true"
HeaderText="Book</br>ReClass" ItemStyle-Width="65px"
UniqueName="BookReclass">
<ItemTemplate>
<asp:Label ID="lblBookReclass" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "BookReclass")%>' Visible="false"></asp:Label>
<telerik:RadNumericTextBox ID="txtBookReclass" runat="server"
EnabledStyle-HorizontalAlign="Right" ReadOnly="false"
Value='<%# DataBinder.Eval(Container.DataItem, "BookReclass")%>' Width="50">
<NumberFormat DecimalDigits="0" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblReClassTotal" runat="server" Visible="true"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle Width="65px" />
</telerik:GridTemplateColumn>
<telerik:GridCalculatedColumn Aggregate="Sum"
DataFields="PerBook, BookAdjustments, BookReclass"
DataFormatString="{0:###,##0}" DataType="System.Double"
Expression="{0}+{1}+{2}" FooterStyle-HorizontalAlign="Right" FooterText=" "
HeaderStyle-Width="65px" HeaderStyle-Wrap="true"
HeaderText="Adjusted</br>Per Book" ItemStyle-HorizontalAlign="Right"
ItemStyle-Width="65px" UniqueName="AdjPerBook">
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle HorizontalAlign="Right" Width="65px" />
</telerik:GridCalculatedColumn>
<telerik:GridTemplateColumn DataField="M1" EditFormColumnIndex="2"
HeaderStyle-Width="65px" HeaderStyle-Wrap="true" HeaderText="M-1"
ItemStyle-Width="65px" UniqueName="M-1">
<ItemTemplate>
<asp:Label ID="lblM1" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "M1")%>' Visible="false"></asp:Label>
<asp:Label ID="lblFieldID" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "FieldID")%>' Visible="false"></asp:Label>
<asp:Label ID="lblCategoryID" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "CategoryID")%>' Visible="false"></asp:Label>
<asp:Label ID="lblSourceTypeID" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "SourceTypeID")%>'
Visible="false"></asp:Label>
<telerik:RadNumericTextBox ID="txtM1" runat="server"
EnabledStyle-HorizontalAlign="Right" ReadOnly="false"
Value='<%# DataBinder.Eval(Container.DataItem, "M1")%>' Width="50">
<NumberFormat DecimalDigits="0" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblM1Total" runat="server" Visible="true"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle Width="65px" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="Eliminations" EditFormColumnIndex="3"
HeaderStyle-Width="65px" HeaderStyle-Wrap="true" HeaderText="Elims"
ItemStyle-Width="65px" UniqueName="Eliminations">
<ItemTemplate>
<asp:Label ID="lblEliminations" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Eliminations")%>'
Visible="false"></asp:Label>
<telerik:RadNumericTextBox ID="txtEliminations" runat="server"
EnabledStyle-HorizontalAlign="Right" ReadOnly="false"
Value='<%# DataBinder.Eval(Container.DataItem, "Eliminations")%>' Width="50">
<NumberFormat DecimalDigits="0" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblEliminationTotal" runat="server" Visible="true"></asp:Label>
</FooterTemplate>
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle Width="65px" />
</telerik:GridTemplateColumn>
<telerik:GridCalculatedColumn Aggregate="Sum"
DataFields="PerBook,BookAdjustments, BookReclass,M1,Eliminations"
DataFormatString="{0:###,##0}" DataType="System.Double"
Expression="{0}+{1}+{2}+{3}+{4}" FooterStyle-HorizontalAlign="Right"
FooterText=" " HeaderStyle-Width="65px" HeaderStyle-Wrap="true"
HeaderText="Total" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="65px"
UniqueName="Total">
<FooterStyle HorizontalAlign="Right" />
<HeaderStyle Width="65px" Wrap="True" />
<ItemStyle HorizontalAlign="Right" Width="65px" />
</telerik:GridCalculatedColumn>
<telerik:GridBoundColumn AllowFiltering="false" DataField="FieldID"
ItemStyle-HorizontalAlign="Left" ShowFilterIcon="false"
SortExpression="FieldID" UniqueName="FieldID" Visible="false">
<ItemStyle HorizontalAlign="Left" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" DataField="CategoryID"
ItemStyle-HorizontalAlign="Left" ShowFilterIcon="false"
SortExpression="CategoryID" UniqueName="CategoryID" Visible="false">
<ItemStyle HorizontalAlign="Left" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" DataField="SourceTypeID"
ItemStyle-HorizontalAlign="Left" ShowFilterIcon="false"
SortExpression="SourceTypeID" UniqueName="SourceTypeID" Visible="false">
<ItemStyle HorizontalAlign="Left" />
</telerik:GridBoundColumn>
<%
--<telerik:GridEditCommandColumn ButtonType="LinkButton" EditText="Edit" HeaderStyle-Width="100px" ItemStyle-Width="25px"></telerik:GridEditCommandColumn>--%>
</Columns>
<%
--<EditFormSettings ColumnNumber="3" >
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" />
<FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2"
Height="110px" Width="100%" />
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
<FormStyle Width="100%" BackColor="#ffffff"></FormStyle>
</EditFormSettings>--
%>
<%
--<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>--
%>
</MasterTableView>
<ClientSettings>
<%
--<Scrolling AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="True" >
</Scrolling>--
%>
<%
--<ClientEvents OnRowClick="RowClick"/>--%>
</ClientSettings>
<%
--<PagerStyle AlwaysVisible="True" />
<FilterMenu EnableImageSprites="False">
</FilterMenu>--
%>
</telerik:RadGrid>
Thanks,
Raghav.
Could you please share yout code behind so I can try replicate the issue on my end and do the best to isolate its root cause?
In most cases the problem could appear in case you are trying to change the RadGrid data source which will make some of the page indexes not valid anymore.
Regards,
Maria Ilieva
the Telerik team