I'm creating an application in ASP.Net where team leaders can edit targets per hour for a specific item. I'm scheduled to present this project to multiple people today and I debugged the project to have a run through and practice my speech.

However, a problem arose. The code where I retrieve the values from the Gridview to be inserted into a database is broken.

The error message I recieve is:

An exception of type 'System.ArgumentOutOfRangeException' occurred in System.Web.dll but was not handled in user code

Additional information: Specified argument was out of the range of valid values.

The code I use to retrieve the values is:

 string contractName = gvShowData.DataKeys[e.RowIndex].Value.ToString();
 GridViewRow row = (GridViewRow)gvShowData.Rows[e.RowIndex];
 TextBox txtContractName = (TextBox)row.Cells[0].FindControl("Contract");
 string txtCName = ((TextBox)row.Cells[1].Controls[0]).Text;
 string txtModel = ((TextBox)row.Cells[2].Controls[0]).Text;
 string txtProcess = ((TextBox)row.Cells[3].Controls[0]).Text;
 string txtH0 = ((TextBox)row.Cells[4].Controls[0]).Text;
 string txtH1 = ((TextBox)row.Cells[5].Controls[0]).Text;
 string txtH2 = ((TextBox)row.Cells[6].Controls[0]).Text;
 string txtH3 = ((TextBox)row.Cells[7].Controls[0]).Text;
 string txtH4 = ((TextBox)row.Cells[8].Controls[0]).Text;
 string txtH5 = ((TextBox)row.Cells[9].Controls[0]).Text;
 string txtH6 = ((TextBox)row.Cells[10].Controls[0]).Text;
 string txtH7 = ((TextBox)row.Cells[11].Controls[0]).Text;
 string txtH8 = ((TextBox)row.Cells[12].Controls[0]).Text;
 string txtH9 = ((TextBox)row.Cells[13].Controls[0]).Text;
 string txtH10 = ((TextBox)row.Cells[14].Controls[0]).Text;
 string txtH11 = ((TextBox)row.Cells[15].Controls[0]).Text;
 string txtH12 = ((TextBox)row.Cells[16].Controls[0]).Text;
 string txtH13 = ((TextBox)row.Cells[17].Controls[0]).Text;
 string txtH14 = ((TextBox)row.Cells[18].Controls[0]).Text;
 string txtH15 = ((TextBox)row.Cells[19].Controls[0]).Text;
 string txtH16 = ((TextBox)row.Cells[20].Controls[0]).Text;
 string txtH17 = ((TextBox)row.Cells[21].Controls[0]).Text;
 string txtH18 = ((TextBox)row.Cells[22].Controls[0]).Text;
 string txtH19 = ((TextBox)row.Cells[23].Controls[0]).Text;
 string txtH20 = ((TextBox)row.Cells[24].Controls[0]).Text;
 string txtH21 = ((TextBox)row.Cells[25].Controls[0]).Text;
 string txtH22 = ((TextBox)row.Cells[26].Controls[0]).Text;
 string txtH23 = ((TextBox)row.Cells[27].Controls[0]).Text;

Related posts

Recent Viewed