Get count of specific rows based on column value from DataTable in C# .Net

Last Reply on Aug 09, 2014 04:14 AM By Azim

Posted on Aug 09, 2014 03:50 AM

 

DataSet ds = new DataSet();
  string vee = "select id,Name,Section,remaining,nextdate,Status from salary where id = '" + TextBox1.Text + "' AND  nextdate BETWEEN '" + TextBox2.Text + "' and '" + TextBox2.Text + "' AND lastdate BETWEEN '" + TextBox4.Text + "' and '" + TextBox4.Text + "' and Status='" + TextBox3.Text + "'";
        
       ds = mvl.GETDS(vee);
       GridView1.DataSource = ds;
        GridView1.DataBind();
       int count = 0;
        foreach (GridViewRow row in this.GridView1.Rows)
        {
            if (row.Cells[5].Text == "Present")
            {
                count++;
            }
        }
        this.Label3.Text = count.ToString();
        Label3.ForeColor = System.Drawing.Color.LightPink;

 

my sql data is

Section  	nextdate	Status		lastdate
BM		10/08/2014	Present		31/8/2014
BM		01/08/2014	Present		31/8/2014
BM		09/08/2014	Present		31/8/2014
BM		09/08/2014	Present		31/8/2014
BM		09/08/2014	Present		31/8/2014

but my output in local server ishttp://s1279.photobucket.com/user/celvs/media/grid_zps383a6804.png.html?filters[user]=140385911&filters[recent]=1&sort=1&o=0

 

 


in label it show 3 days but output is 4 days

This question does not have replies that have been liked.