现在的位置: 首页 > 综合 > 正文

DataGrid保存数据时出现错误解决办法.

2014年09月20日 ⁄ 综合 ⁄ 共 656字 ⁄ 字号 评论关闭
解决办法:
前台设定DataGrid
DataKeyField="ID"

错误提示:


Server Error in '/News' Application.

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: index

Source Error:

Line 93: 		{
Line 94: //取得编辑行的关键字段的值
Line 95: int empID=(int)DataGrid1.DataKeys[e.Item.ItemIndex];
Line 96:
Line 97: //取得文本框中输入的内容

Source File: e:/aspxproject/news/datagridedit.aspx.cs    Line: 95

抱歉!评论已关闭.