Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

C#
string query = "update Questionnaire_UserAnswers set Comments='" + grdView.Rows[].Cells[1].Controls[0] + "', Marks=" + grdView.Rows[4].Cells[5].Controls[0] + " where Question_ID=" + grdView.Rows[0].Cells[1].Controls[0] + "UserName='" + Request.QueryString["UserName"] + "'";

Please Rectify this Error
Posted
Updated 9-Nov-11 20:40pm
v3

check once u are not provided index in gridView1.Rows[] at first value:
C#
grdView.Rows[].Cells[1].Controls[0] 

provide row index
 
Share this answer
 
Well,this means that one of the indexer you are using exceeded the array length.
Make sure that:
1- Your grView have at least 5 rows.
2- Your grView has at least 6 columns.
3- Your 2nd and 6th columns already have at least 1 control in it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900