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. |
|
<telerik:RadGrid ID=
"RadGrid1"
OnPreRender=
"RadGrid1_PreRender"
DataSourceID=
"SqlDataSource1"
OnItemInserted=
"RadGrid1_ItemInserted"
runat=
"server"
AutoGenerateColumns=
"False"
AllowSorting=
"True"
AllowMultiRowSelection=
"False"
AllowPaging=
"True"
PageSize=
"10"
GridLines=
"None"
AllowAutomaticInserts=
"True"
allowautomaticdeletes=
"true"
AllowAutomaticUpdates=
"true"
>
<PagerStyle Mode=
"NumericPages"
></PagerStyle>
<MasterTableView DataSourceID=
"SqlDataSource1"
CommandItemDisplay=
"Top"
DataKeyNames=
"custID"
AllowMultiColumnSorting=
"True"
GroupLoadMode=
"Server"
>
<NestedViewTemplate>
<asp:Panel runat=
"server"
ID=
"InnerContainer"
CssClass=
"viewWrap"
Visible=
"true"
>
<telerik:RadTabStrip runat=
"server"
ID=
"TabStip1"
MultiPageID=
"Multipage1"
SelectedIndex=
"0"
>
<Tabs>
<telerik:RadTab runat=
"server"
Text=
"Job Details"
PageViewID=
"PageView1"
>
</telerik:RadTab>
<telerik:RadTab runat=
"server"
Text=
"Scheduling"
PageViewID=
"PageView2"
>
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat=
"server"
ID=
"Multipage1"
SelectedIndex=
"0"
RenderSelectedPageOnly=
"false"
>
<telerik:RadPageView runat=
"server"
ID=
"PageView1"
>
<asp:Label ID=
"Label1"
Font-Bold=
"true"
Font-Italic=
"true"
Text=
'<%# Eval("custID") %>'
Visible=
"false"
runat=
"server"
/>
<telerik:RadGrid runat=
"server"
ID=
"OrdersGrid"
DataSourceID=
"SqlDataSource2"
ShowFooter=
"true"
AllowSorting=
"true"
EnableLinqExpressions=
"false"
>
<MasterTableView ShowHeader=
"true"
AutoGenerateColumns=
"False"
AllowPaging=
"true"
EditMode=
"InPlace"
DataKeyNames=
"OrderID"
PageSize=
"7"
HierarchyLoadMode=
"ServerOnDemand"
CommandItemDisplay=
"Top"
>
<Columns>
<telerik:GridNumericColumn SortExpression=
"Description"
HeaderText=
"Description"
HeaderButtonType=
"TextButton"
DataField=
"Description"
UniqueName=
"Description"
>
</telerik:GridNumericColumn>
<telerik:GridBoundColumn SortExpression=
"Price"
HeaderText=
"Price"
HeaderButtonType=
"TextButton"
DataField=
"Price"
UniqueName=
"Price"
>
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn SortExpression=
"PayOnline"
HeaderText=
"PayOnline"
HeaderButtonType=
"TextButton"
DataField=
"PayOnline"
UniqueName=
"Payonline"
>
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn UniqueName=
"Frequency"
DataField=
"FrequencyNum"
HeaderText=
"Frequency"
>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID=
"SqlDataSource2"
ConnectionString=
"<%$ ConnectionStrings:MainConnectionString %>"
ProviderName=
"System.Data.SqlClient"
SelectCommand=
"SELECT * FROM CustJobs Where custID = @custID "
runat=
"server"
>
<SelectParameters>
<asp:ControlParameter ControlID=
"Label1"
PropertyName=
"Text"
Type=
"String"
Name=
"custID"
/>
</SelectParameters>
</asp:SqlDataSource>
</telerik:RadPageView>
<telerik:RadPageView runat=
"server"
ID=
"PageView2"
Width=
"600px"
>
<asp:Label ID=
"Label2"
Font-Bold=
"true"
Font-Italic=
"true"
Text=
'<%# Eval("custID") %>'
Visible=
"false"
runat=
"server"
/>
<telerik:RadGrid runat=
"server"
ID=
"RadGrid2"
DataSourceID=
"SqlDataSource2"
ShowFooter=
"true"
AllowSorting=
"true"
EnableLinqExpressions=
"false"
>
<MasterTableView ShowHeader=
"true"
AutoGenerateColumns=
"False"
AllowPaging=
"true"
EditMode=
"InPlace"
DataKeyNames=
"OrderID"
PageSize=
"7"
HierarchyLoadMode=
"ServerOnDemand"
>
<Columns>
<telerik:GridNumericColumn SortExpression=
"FrequencyNum"
HeaderText=
"Frequency"
HeaderButtonType=
"TextButton"
DataField=
"FrequencyNum"
UniqueName=
"FrequencyNum"
>
</telerik:GridNumericColumn>
<telerik:GridBoundColumn SortExpression=
"FrequencyTerm"
HeaderText=
".."
HeaderButtonType=
"TextButton"
DataField=
"FrequencyTerm"
UniqueName=
"FrequencyTerm"
>
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn SortExpression=
"FirstClean"
HeaderText=
"FirstClean"
HeaderButtonType=
"TextButton"
DataField=
"FirstClean"
UniqueName=
"FirstClean"
>
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn UniqueName=
"NextDue"
HeaderText=
"Next Due"
HeaderButtonType=
"TextButton"
DataField=
"NextDue"
>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID=
"SqlDataSource3"
ConnectionString=
"<%$ ConnectionStrings:MainConnectionString %>"
ProviderName=
"System.Data.SqlClient"
SelectCommand=
"SELECT * FROM CustJobs Where custID = @custID "
runat=
"server"
>
<SelectParameters>
<asp:ControlParameter ControlID=
"Label1"
PropertyName=
"Text"
Type=
"String"
Name=
"custID"
/>
</SelectParameters>
</asp:SqlDataSource>
</telerik:RadPageView>
</telerik:RadMultiPage>
</asp:Panel>
</NestedViewTemplate>
<Columns>
<telerik:GridBoundColumn DataField=
"custID"
SortExpression=
"custID"
HeaderText=
"custID"
Visible=
"false"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Name"
HeaderText=
"Name"
HeaderButtonType=
"TextButton"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Name"
UniqueName=
"Name"
ItemStyle-Width=
"5"
HeaderStyle-Width=
"5"
FilterControlWidth=
"5"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Addr1"
HeaderText=
"Address"
HeaderButtonType=
"TextButton"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Addr1"
UniqueName=
"Addr1"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Addr2"
HeaderText=
""
HeaderButtonType=
"TextButton"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Addr2"
UniqueName=
"Addr2"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Town"
HeaderText=
"Town"
HeaderButtonType=
"TextButton"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Town"
UniqueName=
"Town"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"County"
HeaderText=
"County"
HeaderButtonType=
"TextButton"
ItemStyle-Font-Size=
"Smaller"
DataField=
"County"
UniqueName=
"County"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"PostCode"
HeaderText=
"PostCode"
HeaderButtonType=
"TextButton"
MaxLength=
"8"
ItemStyle-Font-Size=
"Smaller"
DataField=
"PostCode"
UniqueName=
"PostCode"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Tel"
HeaderText=
"Tel"
HeaderButtonType=
"TextButton"
MaxLength=
"11"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Tel"
UniqueName=
"Tel"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Mobile"
HeaderText=
"Mobile"
HeaderButtonType=
"TextButton"
MaxLength=
"11"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Mobile"
UniqueName=
"Mobile"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression=
"Email"
HeaderText=
"Email"
HeaderButtonType=
"TextButton"
ItemStyle-Font-Size=
"Smaller"
DataField=
"Email"
UniqueName=
"Email"
>
</telerik:GridBoundColumn>
<telerik:GridEditCommandColumn ButtonType=
"ImageButton"
UniqueName=
"EditCommandColumn"
>
<ItemStyle CssClass=
"MyImageButton"
/>
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowDragToGroup=
"true"
/>
</telerik:RadGrid>
Protected
Sub
RadGrid1_PreRender(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Handles
RadGrid1.PreRender
'REPLACE with oleDB method b4 go live
'----------
Dim
strGUID2Find
As
String
strGUID2Find = Session(
"CustGUID"
)
'-------------
'use session var for debugging.. switch to OLEDB method before go live.
' Do nothing if RadGrid is in insert mode or no new item is inserted recently.
If
RadGrid1.MasterTableView.IsItemInserted
OrElse
strGUID2Find =
""
Then
Return
End
If
Dim
currentPageIndex
As
Integer
= RadGrid1.CurrentPageIndex
' loop thru grid to find latest rec inserted..
For
i
As
Integer
= 0
To
RadGrid1.PageCount - 1
' Compare CustID of each item in the RadGrid with the newly inserted item custID
For
Each
item
As
GridDataItem
In
RadGrid1.Items
If
strGUID2Find.Equals(item(
"CustID"
).Text)
Then
' Select the last inserted row
item.Selected =
True
item.Expanded =
True
Dim
tableView
As
GridTableView =
DirectCast
(item.ChildItem.NestedTableViews(0), GridTableView)
tableView.IsItemInserted =
True
currentPageIndex = -1
' flag exit
Exit
For
End
If
Next
' If item is found then exit RadGrid page loop
If
currentPageIndex.Equals(-1)
Then
Exit
For
End
If
' Go to next RadGrid page
currentPageIndex += 1
If
currentPageIndex >= RadGrid1.PageCount
Then
currentPageIndex = 0
End
If
RadGrid1.CurrentPageIndex = currentPageIndex
RadGrid1.Rebind()
Next
End
Sub
I ran into this error and I wanted to post my work around to it. I was trying to add a popup warning to an existing edit button that kicked off an edit for a grid. The error I got is below.
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.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: ItemHierarchicalIndex
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:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: ItemHierarchicalIndex]
Telerik.Web.UI.GridDataItemCollection.get_Item(String hierarchicalIndex) +113
Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +3642
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
What caused this error was the javascript I added to fire the grid_ItemCommand after the popup. It was firing off code inside the RadGrid Control before it ever got to my codebehind and this code was having the error.
Bad Code
<Telerik:RadScriptBlock ID=
"RadScriptBlock1"
runat=
"server"
>
<script language=
"javascript"
type=
"text/javascript"
>
function
confirmEdit() {
// This function prompts the user if they want to edit (Y/N).
<% If ShowPopup Then %>
radconfirm(
"The date selected is a prior period date, are you sure you want to edit the data for the date shown?"
, confirmCallBackFnEdit, 330, 100,
null
,
'Edit Receipt Noms (Y/N)'
);
<% Else %>
var
masterTable = $find(
"<%= RadGrid1.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"Edit"
,
""
);
<% End If %>
}
function
confirmCallBackFnEdit(arg) {
if
(arg) {
var
masterTable = $find(
"<%= RadGrid1.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"Edit"
,
""
);
}
}
</script>
</Telerik:RadScriptBlock>
To fix this error I renamed the CommandName I was looking for in the code behind Grid_ItemCommand from Edit to EditAll, changed the commandname on the button in HTML to EditAll and I changed the javascript to call EditAll. This bypassed the code inside the RadGrid control causing the error.
Good Code
<Telerik:RadScriptBlock ID=
"RadScriptBlock1"
runat=
"server"
>
<script language=
"javascript"
type=
"text/javascript"
>
function
confirmEdit() {
// This function prompts the user if they want to edit (Y/N).
<% If ShowPopup Then %>
radconfirm(
"The date selected is a prior period date, are you sure you want to edit the data for the date shown?"
, confirmCallBackFnEdit, 330, 100,
null
,
'Edit Receipt Noms (Y/N)'
);
<% Else %>
var
masterTable = $find(
"<%= RadGrid1.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"EditAll"
,
""
);
<% End If %>
}
function
confirmCallBackFnEdit(arg) {
if
(arg) {
var
masterTable = $find(
"<%= RadGrid1.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"EditAll"
,
""
);
}
}
</script>
</Telerik:RadScriptBlock>
It looks like a button CommandName of Edit should be treated like a reserved word until Telerik fixes this issue.