Israel

Israel

  • 631
  • 1.3k
  • 217.3k

Should sumarize totals's column with blank rows as null or 0

Jan 5 2017 8:30 AM
Hi!
When I make a filter its stuggs or block. Doesnt do the filter. I realize that the my Totals's column have some blank rows. Then how can I do to considerate all blank rows as null or "0".
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from cadastramento where year= ?";
var param1 = new OleDbParameter("@year", OleDbType.VarChar); // use actual type of 'name' here
param1.Value = cbxYear.Text; // or whatever
cmd.Parameters.Add(param1);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
conn.Close();
dGVCons.DataSource = dt;
this.dGVCons.RowsDefaultCellStyle.BackColor = Color.AliceBlue;
this.dGVCons.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
int sum = 0;
for (int i = 0; i < dGVCons.Rows.Count; ++i)
{
sum += Convert.ToInt32(dGVCons.Rows[i].Cells["total_Clothes"].Value);
lblTotalClothes.Text = " " + sum.ToString();
int sum1 = 0;
for (int i1 = 0; i1 < dGVCons.Rows.Count; ++i1)
{
sum1 += Convert.ToInt32(dGVCons.Rows[i1].Cells["total_Shoes"].Value);
lblTotalShoes.Text = " " + sum1.ToString();

Answers (6)