shahab
Junior Contributor
Dear Friends,
I am using a pagable datagrid and a session like this:
Session["NewsId"]=DataGrid1.DataKeys[(int)e.Item.ItemIndex];
When I browsing through the pages of datagrid this error is shown to me:
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 179: {
Line 180: //Label3.Text=DataGrid1.DataKeys[(int)e.Item.ItemIndex].ToString();
Line 181: Session["NewsId"]=DataGrid1.DataKeys[(int)e.Item.ItemIndex];
What should I do in order to solve this problem?
I am using a pagable datagrid and a session like this:
Session["NewsId"]=DataGrid1.DataKeys[(int)e.Item.ItemIndex];
When I browsing through the pages of datagrid this error is shown to me:
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 179: {
Line 180: //Label3.Text=DataGrid1.DataKeys[(int)e.Item.ItemIndex].ToString();
Line 181: Session["NewsId"]=DataGrid1.DataKeys[(int)e.Item.ItemIndex];
What should I do in order to solve this problem?