在Datagrid控件上添加了linkbutton,实现删除功能,老是出现这个问题.头都大了,特来求救``
哦米佗佛,善哉善哉.Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
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: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: indexSource Error:
Line 168: protected void DataGrid1_DeleteCommand(Object sender,DataGridCommandEventArgs e)
Line 169: {
Line 170: int ID =(int)DataGrid1.DataKeys[(int)e.Item.ItemIndex];
Line 171:
Line 172: Conn con=new Conn();
Source File: c:\inetpub\wwwroot\richscrm\richs\admin\adminspeo.aspx.cs Line: 170 Stack Trace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +91
System.Web.UI.WebControls.DataKeyCollection.get_Item(Int32 index) +10
admin.AdminSPeo.DataGrid1_DeleteCommand(Object sender, DataGridCommandEventArgs e) in c:\inetpub\wwwroot\richscrm\richs\admin\adminspeo.aspx.cs:170
System.Web.UI.WebControls.DataGrid.OnDeleteCommand(DataGridCommandEventArgs e) +110
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +589
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +106
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277
谢答,过多垃圾信息还望眼谅
哦米佗佛,善哉善哉.Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
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: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: indexSource Error:
Line 168: protected void DataGrid1_DeleteCommand(Object sender,DataGridCommandEventArgs e)
Line 169: {
Line 170: int ID =(int)DataGrid1.DataKeys[(int)e.Item.ItemIndex];
Line 171:
Line 172: Conn con=new Conn();
Source File: c:\inetpub\wwwroot\richscrm\richs\admin\adminspeo.aspx.cs Line: 170 Stack Trace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +91
System.Web.UI.WebControls.DataKeyCollection.get_Item(Int32 index) +10
admin.AdminSPeo.DataGrid1_DeleteCommand(Object sender, DataGridCommandEventArgs e) in c:\inetpub\wwwroot\richscrm\richs\admin\adminspeo.aspx.cs:170
System.Web.UI.WebControls.DataGrid.OnDeleteCommand(DataGridCommandEventArgs e) +110
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +589
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +106
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277
谢答,过多垃圾信息还望眼谅
解决方案 »
- 怎么触发gridview 的SelectedIndexChanged事件?
- 服务器为页面显示数据付出的代价讨论。
- 高分gridview的问题
- 添加数据后,在GRIDVIEW绑定中不能显示出新添加的数据,重启电脑后才能好
- ajax返回值的問題
- 关于站内搜索引擎的架设问题
- 高分求绘制实时曲线的源代码!(问题解决。另外再高分相送)
- 文件下载:不在浏览器中打开,让直接出现下载对话框,中文文件名出错??
- DATAGRID控件用模版,页脚用DROPDOWNLIST控件,如何绑定另一个表的数据
- IIS中修改XML文件,缓存没有更新
- 请问我想在一个页面加一个关闭按钮直接就关了这一页,要怎样写程序才能直接关了呢?
- 求一正则表达式
{
int ID =(int)DataGrid1.DataKeys[(int)e.Item.ItemIndex];//这句始终出问题,头都大了 Conn con=new Conn(); con.Execute("DELETE FROM 员工档案 WHERE ID="+ID);
Bindata(); }