请教个问题,我想针对datagridview所查出来行数,求个合计,合计数显示在下面文本框里面,请问这个语句怎么写呢,只是有多少行数的合计就行,不用求具体值的和;
敬请指导,我是如下那样写得,但没有作用,不显示合计行;
int count = dataGridView1.RowCount;
int text = 0;
for (int i = 0; i < count; i++)
{
string value = Convert.ToString(dataGridView1.Rows[i].Cells[0].Value);
if (!string.IsNullOrEmpty(value))
{
text += Convert.ToInt32(value);
textBox1.Text = text.ToString();
}
}