Index was out of range. Must be non-negative and less than the size of the collection.
-
Hi all, Below is my gridview This is the code for deleting a row protected void bcgrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(bcgrid.DataKeys[e.RowIndex].Values[0].ToString()); Delete(id); } I am getting the error Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Can anybody help me in come out of this error Thanks in Advance
-
Hi all, Below is my gridview This is the code for deleting a row protected void bcgrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(bcgrid.DataKeys[e.RowIndex].Values[0].ToString()); Delete(id); } I am getting the error Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Can anybody help me in come out of this error Thanks in Advance
-
At which line you are getting error?The error says,that the id doesn't fall in index range vailable.Debug the code and check the id and available index range.
Cheers!! Brij
int id = Convert.ToInt32(bcgrid.DataKeys[e.RowIndex].Values[0].ToString()); ths line gives error
-
int id = Convert.ToInt32(bcgrid.DataKeys[e.RowIndex].Values[0].ToString()); ths line gives error
-
Hi all, Below is my gridview This is the code for deleting a row protected void bcgrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(bcgrid.DataKeys[e.RowIndex].Values[0].ToString()); Delete(id); } I am getting the error Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Can anybody help me in come out of this error Thanks in Advance
In the code-behind, you are using DataKeyItem's Index, but you are not telling to the program what datakeys are. For the GridView control, you have to specify DataKeyNames property.
Ashok kumar.