Here is my code, I am trying to display multiplication of Rate * Supply
column values and assigning it to the Amount
column in data grid view :
try
{
Query = "Select id,Code,Description,Rate,Cust_Id,Supply,Empty,Amount,Received from Items ";
adap = new SQLiteDataAdapter(Query, GlobalVars.conn);
ds = new DataSet();
adap.Fill(ds, "Items");
dtgVOuchers.DataSource = ds.Tables[0];
ds.Tables[0].Columns["Amount"].DefaultValue = (ds.Tables[0].Columns["Rate"].DefaultValue) * (ds.Tables[0].Columns["Supply"].DefaultValue); //error
//dtgVOuchers.Rows.Clear();
ds.Tables[0].Clear();
dtgVOuchers.Refresh();
}
Does anyone know how I can accomplish this functionality in data grid view ? . .Please help me to correct this code. Thanks
foreach (DataGridViewRow row in dtgVOuchers.Rows)
{
row.Cells[dtgVOuchers.Columns["Amount"].Index].Value = (Convert.ToDouble(row.Cells[dtgVOuchers.Columns["Rate"].Index].Value) * Convert.ToDouble(row.Cells[dtgVOuchers.Columns["Supply"].Index].Value));
}