如何计算datagrid记录 [英] how can count datagrid recoard
本文介绍了如何计算datagrid记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void button4_Click(object sender, EventArgs e)
{
if (txtcombo.Text == "Form ID")
{
label1.Hide();
Global.Open_DataConn("doc", "conData");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT WCDCH.formid, WCDCH.surname, WCDCH.firstname, WCDCH.midname, WCDCH.ttransid FROM WCDCH INNER JOIN bankdata ON WCDCH.formid = bankdata.formid", Global.conData);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
label2.Show();
label3.Text = dataGridView1.RowCount.ToString();
}
else if (txtcombo.Text == "TransactionID")
{
label2.Hide();
Global.Open_DataConn("doc", "conData");
OleDbDataAdapter da = new OleDbDataAdapter("SELECT WCDCH.formid, WCDCH.surname, WCDCH.firstname, WCDCH.midname, WCDCH.ttransid FROM WCDCH INNER JOIN bankdata ON WCDCH.ttransid = bankdata.ttransid", Global.conData);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
label1.Show();
label3.Text = dataGridView1.RowCount.ToString();
}
else
{
MessageBox.Show("Please,Select which you want");
}
}
我已经在datagrid中完成了从数据库中获取匹配记录的操作,现在我需要对datagrid中显示的结果进行计数..
i have done the get matching record from the database in datagrid now i need to count the result shown in the datagrid..
推荐答案
简单使用表中的行数,例如
simple use number of rows in tables like
int noofRec ds.Tables[0].rows.count;
label3.Text = dataGridView1.RowCount.ToString();
label3.Text = dataGridView1.RowCount.ToString();
这篇关于如何计算datagrid记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文