The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.
int sum = 0;
foreach (DataRow rows in dt.Rows)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
for (int j = 0; j < dt.Rows.Count; j++)
{
int number = Convert.ToInt32(dt.Rows[j].Field<int>(i));
sum += number;
}
}
rows["testrow"] = sum;
}
dataGridView1.DataSource = dt;
}
foreach (DataRow rows in dt.Rows)
{
int sum_row = 0;
for (int i = 0; i < dt.Columns.Count ; i++)
{
int number = Convert.ToInt32(rows.Field<int>(i));
sum_row += number;
}
rows.Field( dt.Columns) = sum_row;
}
dataGridView1.DataSource = dt;
System.Data.DataTable dt = ds.Tables[0];
dt.Columns.Add("testrow", typeof(int));
DataRow dr = dt.NewRow();
int sum = 0;
for (int i = 1; i < dt.Columns.Count; i++)
{
for (int j = 1; j < dt.Rows.Count; j++)
{
if (j == dt.Rows.Count - 1)
{
dt.Rows[i][j] = Convert.ToInt32(sum);
sum = 0;
}
else
{
object number = dt.Rows[i][j];
sum += Convert.ToInt32(number);
}
}
dataGridView1.DataSource = dt;
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Using C#, how could you improve upon my method of writing out a merged, compressed file? | 2 | 46 | |
Need a starter for ETL protocol? | 4 | 56 | |
Modal Popup Extender control | 1 | 20 | |
JQuery JavaScripot loop though RadioButtonList | 4 | 25 |
Join the community of 500,000 technology professionals and ask your questions.