I've searched and am now at a loss as to the cause of my problem.
Here's the short version of my issue.
I have a gridview, a checkbox to toggle paging of the gridview on/off and a sql datasource with select and delete queries. If paging is on, I can click delete for a row in the gridview and it runs and the page refreshes no problem. If I turn paging off for the gridview, the delete query appears to run when I do a direct query against the table in sql server but the page fails to reload. I get the following error:
Specified argument was out of the range of valid values. Parameter name: value 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: value
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: value]
System.Web.UI.WebControls.GridView.set_SelectedIndex(Int32 value) +280
System.Web.UI.WebControls.GridView.HandleDeleteCallback(Int32 affectedRows, Exception ex) +352
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +119
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +938
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1152
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +190
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4920
Here is the page code:
<asp:SqlDataSource ID="dsSQL_ClaimsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:activeDB_Connection %>"
DeleteCommand="DELETE FROM [tblReturnClaimDetail] WHERE [ID] = @ID" ProviderName="<%$ ConnectionStrings:activeDB_Connection.ProviderName %>"
SelectCommand="SELECT ID, HeaderID, CustomerSKUData, NikeInvoiceOrSalesOrderNumber, StyleandColorCode, StyleCode, ColorCode, StyleName, WholesaleDolrs, OriginalWholesaleDolrsPerUnit, Units, AccountDiscDolrsPerUnit, TotalNetPriceDolrs, HandlingandProcessing, Negotiated, NegotiatedReason, NegotiatedOptionType, NegotiatedOptionValue, FinalUnitPrice, FinalDolrs, FinalStandardDolrs, UpdateTime, UpdateUser, BatchUser, Approved, Denied, Pending, ClaimDisposition, FinalDecisionDate, ClaimRecordNumber, ASMName, Category, Gender, Other1, Other2, Other3, GBURegion, Division, BudgetManagerName, ClaimsBudgetYear, ClaimsBudgetQuarter, ApprovedDate, ReconciledBy, ReconciledDate, ReconcileOrigionalLineID FROM tblReturnClaimDetail WHERE (HeaderID = @claimID)">
<DeleteParameters>
<asp:Parameter Name="ID" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="lbl_ClaimNumber" Name="claimID" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<asp:CheckBox ID="chkbox_detailPagerToggle" runat="server" Text="View all styles at once" Visible="True" AutoPostBack="True" Checked="True" /> </div>
<asp:GridView ID="grid_Details" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="dsSQL_ClaimsDetail">
<Columns>
<asp:CommandField SelectText="Edit" ShowSelectButton="True">
<HeaderStyle BackColor="Transparent" />
</asp:CommandField>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="NikeInvoiceOrSalesOrderNumber" HeaderText="Nike Invoice /<br />Sales Order #"
HtmlEncode="False" SortExpression="NikeInvoiceOrSalesOrderNumber" />
<asp:BoundField DataField="StyleCode" HeaderText="Style Code" SortExpression="StyleCode" />
<asp:BoundField DataField="ColorCode" HeaderText="Color Code" SortExpression="ColorCode" />
<asp:BoundField DataField="StyleName" HeaderText="Style Name" SortExpression="StyleName" />
<asp:BoundField DataField="GBURegion" HeaderText="Channel" SortExpression="GBURegion" />
<asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />
<asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
<asp:BoundField DataField="OriginalWholesaleDolrsPerUnit" DataFormatString="{0:c2}"
HeaderText="WholeSale<br />$/Unit" HtmlEncode="False" SortExpression="OriginalWholesaleDolrsPerUnit" />
<asp:BoundField DataField="Units" HeaderText="Units" SortExpression="Units" />
<asp:BoundField DataField="AccountDiscDolrsPerUnit" DataFormatString="{0:c2}" HeaderText="Discount<br />$/Unit"
HtmlEncode="False" SortExpression="AccountDiscDolrsPerUnit" />
<asp:BoundField DataField="HandlingandProcessing" DataFormatString="{0:c2}" HeaderText="Handling &<br />Processing"
HtmlEncode="False" SortExpression="HandlingandProcessing" />
<asp:CheckBoxField DataField="Negotiated" HeaderText="Negotiated" SortExpression="Negotiated" />
<asp:BoundField DataField="NegotiatedReason" HeaderText="Negotiated Reason" SortExpression="NegotiatedReason" />
<asp:BoundField DataField="NegotiatedOptionType" HeaderText="Negotiated Type" SortExpression="NegotiatedOptionType" />
<asp:BoundField DataField="NegotiatedOptionValue" HeaderText="Negotiated Value" SortExpression="NegotiatedOptionValue" />
<asp:BoundField DataField="FinalDolrs" DataFormatString="{0:c2}" HeaderText="Final $ for Product"
HtmlEncode="False" SortExpression="FinalDolrs">
<ItemStyle Font-Bold="True" />
</asp:BoundField>
<asp:CommandField ShowDeleteButton="True">
<HeaderStyle BackColor="Transparent" />
</asp:CommandField>
</Columns>
</asp:GridView>
The only code behind for the 3 objects in question is on the checkbox:
Protected Sub chkbox_detailPagerToggle_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkbox_detailPagerToggle.CheckedChanged
If Me.chkbox_detailPagerToggle.Checked = True Then
Me.grid_Details.AllowPaging = False
Else
Me.grid_Details.AllowPaging = True
End If
End Sub
Any ideas to get me looking in the right direction would be wonderful because I am at a loss for where to go next to solve this one.