Hello Mr.Kahlid her's your solution
The below code is written in combobox selected index change u can write it in button click, it will count the total number of rows present in grid view and print it in a messagebox
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int x=0;
SqlConnection connect = new SqlConnection();
connect.ConnectionString = "Data Source=.;Initial Catalog=RJIT;Integrated Security=True";
connect.Open();
string mycommand = "select * from Inquiry_Table where time_of_inquiry='" + comboBox1.Text + "'";
SqlCommand cmd = new SqlCommand(mycommand, connect);
SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = cmd;
DataSet ds = new DataSet();
DataTable dt;
adp.Fill(ds);
dt = ds.Tables[0];
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read() == true)
{
dataGridView1.Visible = true;
dataGridView1.DataSource = dt;
x = x + 1;
}
MessageBox.Show("Total Inquiry found " + x.ToString(),"Information",MessageBoxButtons.OK,MessageBoxIcon.Information);
connect.Close();
}
Do rate my answer once u find it useful
Thanks & Regards
Radix :)