i have datatable with 2 columns,"Debit" & "Credit", and a variable which store my input opening balance. All i want is two get "account balance" by "OpeningBalance-(credit+Debit)".
Note: the debit and credit columns are dynamically as it depends on my date. So how to find opening balance with above mention formula apply on datagrid.
- //for column names and table names
- dataGridView1.ColumnCount = 4;
- dataGridView1.AutoGenerateColumns = false;
- dataGridView1.Columns[0].HeaderText = "NewComments";
- dataGridView1.Columns[0].DataPropertyName = "Comments";
- dataGridView1.Columns[1].HeaderText = "NewDebit_Amount";
- dataGridView1.Columns[1].DataPropertyName = "Debit_Amount";
- dataGridView1.Columns[2].HeaderText = "NewCredit_Amount";
- dataGridView1.Columns[2].DataPropertyName = "Credit_Amount";
"dd=datatable name"
- for (int i = 0; i < dd.Rows.Count-1; i++)
- {
- // //dataGridView1.Rows[i].Cells[12].Value = (dataGridView1.Rows[i].Cells[5].Value.ToString()) +
- // //(dataGridView1.Rows[4].Cells[2].Value.ToString()).ToString();
- dataGridView1.Rows[i].Cells["NEWTotalPrice"].Value = (Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value.ToString())) + (Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value.ToString()));
- }
- dataGridView1.DataSource = dd;
But it gives error, datagridview returns null.
Rajanikant HawaldarPosted May 1, 2020, 6:41 AM
Shehroz ImranPosted May 1, 2020, 6:30 AM
Rajanikant HawaldarPosted May 1, 2020, 4:09 AM
Salman BegPosted May 1, 2020, 3:39 AM