'指定的参数超出有效值范围。参数名称:索引'

时间:2019-04-22 08:33:12

标签: c# asp.net

当我运行应用程序时。我在上面的代码中收到以下异常:

  

指定的参数超出有效值参数的范围   索引

我不确定为什么。控制器中的代码如下:

GridViewRow row = (sender as Button).NamingContainer as GridViewRow;
string pid = (row.Cells[0].Controls[0] as Label).Text;
string name = (row.Cells[1].Controls[0] as TextBox).Text;
string Desc = (row.Cells[2].Controls[0] as TextBox).Text;
string price = (row.Cells[3].Controls[0] as TextBox).Text;
DataTable dt = ViewState["dt"] as DataTable;
dt.Rows[row.RowIndex]["product_name"] = name;
dt.Rows[row.RowIndex]["product_desc"] = Desc;
dt.Rows[row.RowIndex]["product_price"] = price;
ViewState["dt"] = dt;
GridView1.EditIndex = -1;
this.BindGrid();

0 个答案:

没有答案