请教个问题,我想针对datagridview所查出来行数,求个合计,合计数显示在下面文本框--合计数量里面,我所写得语句如下 ,运行有报错,敬请指导,谢谢;
if (this.comboBox1.SelectedIndex == 0)//comboBox1下拉框选择笫一项
{
conn = new SqlConnection("server=.;database=focus_wohua;user=sa;password=whyy"); ;
SqlCommand cmd = new SqlCommand("SELECT * FROM dbo.cx_cxinputm WHERE cyear like '%" + textBox2.Text + "%' AND cmonth like '%" + textBox3.Text + "%' AND ISNULL(biszf,'') != '是' ", conn);
//数据适配器
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
//DataTable存储数据
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
int count = dataGridView1.RowCount;
int text = 0;
for (int i = 0; i < count; i++)
{
int value = Convert.ToInt32( dt.Rows[0]["Value"]); ;
if (!string.IsNull Or Empty(value))
{
text += Convert.ToInt32(value);
}
}
textBox1.Text = text.ToString();
}