protected void GrdOrder_EditCommand(object source, DataGridCommandEventArgs e) { try { int OID = Convert.ToInt32(GrdOrder.DataKeys[e.Item.ItemIndex]); DatabaseHelper db = new DatabaseHelper(); int rowIndex = 0; db.GetProductByOrderID(Convert.ToInt32(OID)); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { for (int i = 1; i <= ds.Tables[0].Rows.Count; i++) { TextBox box1 = (TextBox)GrdProduct.Rows[rowIndex].Cells[1].FindControl("txtitemname"); TextBox box2 = (TextBox)GrdProduct.Rows[rowIndex].Cells[1].FindControl("txtqty"); TextBox box3 = (TextBox)GrdProduct.Rows[rowIndex].Cells[1].FindControl("txtprice"); box1.Text = ds.Tables[0].Rows[0]["ProductName"].ToString(); box2.Text = ds.Tables[0].Rows[0]["Quantity"].ToString(); box3.Text = ds.Tables[0].Rows[0]["Price"].ToString(); rowIndex++; } } } } catch (Exception ex) { lblerror.Visible = true; lblerror.InnerText = ex.Message.ToString(); } }
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)