I am entering value to cell in datagridview from datatable. But it gives me an error. I do it in CellEnterEvent of dataGrid.
if (DataGrid.CurrentCell.ColumnIndex == 6)
{
string getprice = "SELECT " + DataGrid.SelectedRows[0].Cells[3].Value.ToString() + " FROM " +
"" + DataGrid.SelectedRows[0].Cells[2].Value.ToString() + "_Mstr ";
DataTable dt = globalData.q.select(getprice);
DataGrid.CurrentCell.Value = dt.Rows[0][0].ToString();
}
if (DataGrid.CurrentCell.ColumnIndex == 7)
{
if (DataGrid.SelectedRows[0].Cells[5].Value.ToString() != "" && DataGrid.SelectedRows[0].Cells[6].Value.ToString() != "")
DataGrid.CurrentCell.Value = Convert.ToDouble(DataGrid.SelectedRows[0].Cells[5].Value) * Convert.ToDouble(DataGrid.SelectedRows[0].Cells[6].Value);
else
DataGrid.CurrentCell.Value = 0;
}
In other cell (column Index = 7), it works perfrctly, but when entering the value in cell no 6 from Datatable it gives me an error. (The type of both values are same.) The error is
The following error occurred in datagridview :
System.Exception:0.91is not valid value for Int32.---->
System.FormatException: Input string was not in a correct format.
at System.Number.String.ToNumber(String str, NumberStyle options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at...
(Too long to write.)Any help?