Reputation: 43
I tried with this code..
for (int i = 0; i < datagridItemEntry.RowCount; i++)
{
int a = Convert.ToInt32(datagridItemEntry.Rows[i].Cells[4].Value);
int b = Convert.ToInt32(datagridItemEntry.Rows[i].Cells[5].Value);
int c = a * b;
datagridItemEntry.SelectedRows[i].Cells[6].Value = c.ToString();
}
I want value of cell 4 & 5 to be get multiplied and the result should be reflect in cell 6.. Nothing is happening with the above code.. Help me with the proper code..
Upvotes: 1
Views: 998
Reputation:
Your problem may be here
datagridItemEntry.SelectedRows[i].Cells[6].Value = c.ToString();
Replace .SelectedRows
to .Rows
for (int i = 0; i < datagridItemEntry.RowCount; i++)
{
int a = Convert.ToInt32(datagridItemEntry.Rows[i].Cells[4].Value);
int b = Convert.ToInt32(datagridItemEntry.Rows[i].Cells[5].Value);
int c = a * b;
datagridItemEntry.Rows[i].Cells[6].Value = c.ToString();
}
Upvotes: 2