private void DataGridDataInsert() { DataGridViewRow dgr; int i; string Pname,amount,inerID ; DateTime insertdt; //double amount; for (i = 0; i < (dtProductTray.Rows.Count - 1); i++) { dgr = dtProductTray.Rows[i]; //Shown Error : in below line: insertdt= Convert.ToDateTime(dgr.Cells[2].Value);//The string was not recognized as a valid DateTime. There is a unknown word starting at index 0. amount = dgr.Cells[3].Value.ToString(); inerID =dgr.Cells[0].Value.ToString(); DB_Manager.UpdateData("update datatable set insert_date='" +Convert.ToDateTime( insertdt.ToString("MM/dd/yyyy")) + "',amount=" + amount.ToString() + " where iner_id=" + inerID + " "); } }
Quote:Ok, it was cell index problem, it would be Cells[1] itstead of Cells[2]. so it is solved
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)