当我从网格视图中删除一行时,我收到以下错误。 “指定的参数超出了有效值的范围。参数名称:值”。 以下是堆栈跟踪:
[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";
}
答案 0 :(得分:2)
您似乎正在尝试将selectedindex设置为错误的索引。你是否在删除回调或页面加载(prender,...)中的某个地方手动设置它?