Problem: GridView1.DataKeys [e. RowIndex]. Value. ToString () must be non-negative and smaller than the set size.
Exception information: System. Web. HttpUnhandledException:
The System. Web. HttpUnhandledException type is thrown. --->
System. ArgumentOutOfRangeException: The index is out of the range. It must be a non-negative value and smaller than the set size.
Error location: GridView1.DataKeys [e. RowIndex]. Value. ToString ().
Solution: you only need to add the field name that is set as the primary key in the DataKeyNames item of the GridView list attribute.
Problem: GridView1.DataKeys [e. RowIndex]. Value. ToString () must be non-negative and smaller than the set size.
Exception information: System. Web. HttpUnhandledException:
The System. Web. HttpUnhandledException type is thrown. --->
System. ArgumentOutOfRangeException: The index is out of the range. It must be a non-negative value and smaller than the set size.
Error location: GridView1.DataKeys [e. RowIndex]. Value. ToString ().
Solution: you only need to add the field name that is set as the primary key in the DataKeyNames item of the GridView list attribute.