指定的参数超出有效值范围.参数名称:value

本文关键字:参数 value 范围 有效值 | 更新日期: 2023-09-27 18:17:46

当我从网格视图中删除一行时,我得到以下错误。"指定的参数超出有效值范围。参数名称:"value"。下面是堆栈跟踪:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value]
   System.Web.UI.WebControls.GridView.set_SelectedIndex(Int32 value) +1353411
   System.Web.UI.WebControls.GridView.HandleDeleteCallback(Int32 affectedRows, Exception ex) +368
   System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +137
   System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +714
   System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +869
   System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

请推荐我。

。我没有手动设置任何索引。我的代码示例如下:'>'>

            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="srcData" runat="server" ConnectionString="<%$ ConnectionStrings:GermanyCockpitDB %>"
            SelectCommand="SP_BPGetData" SelectCommandType="StoredProcedure"
            OnSelecting="srcBP_Selecting" DeleteCommand="SP_BPDeleteRecord"
            DeleteCommandType="StoredProcedure" OnDeleting="srcData_deleting">
            <SelectParameters>
                <asp:Parameter Name="Manager" Type="String" />
                <asp:Parameter Name="Period1" Type="String" />
                <asp:Parameter Name="Period2" Type="String" />
                <asp:Parameter Name="Period3" Type="String" />
                <asp:Parameter Name="Period4" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="ManagerName" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="AName" Type="String" />
            </DeleteParameters>
        </asp:SqlDataSource><br /><br />  protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        gvData.DataSourceID = "srcData";
        gvData.DataBind();
    }
}protected void srcData_deleting(object sender, SqlDataSourceCommandEventArgs e)
{
    e.Command.Parameters["@ManagerName"].Value = "Sample";
}
protected void srcBP_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    e.Command.Parameters["@ReportsToManager"].Value = "Sample";
    e.Command.Parameters["@Period1"].Value = "0";
    e.Command.Parameters["@Period2"].Value = "1";
    e.Command.Parameters["@Period3"].Value = "2";
    e.Command.Parameters["@Period4"].Value = "3";
}

指定的参数超出有效值范围.参数名称:value

似乎你试图设置一个错误的索引。您是否在删除回调或页面加载(加载,…)中手动设置它?